none
Excel transfer data from one sheet to another RRS feed

  • Question

  • Hi,

    I have made a sheet with an code in BVA to tansfer entered data to another sheet. This is working fine, but I want to assign a specific cells in sheet2 t copy too. I now copies the data atomatically from the top of the sheet. Is it possible to make the entries start from another point. Can Anyone take a look a my code? How can I add to this code.

    Thank you in advance.

    Kind regards,

    Iris

    Private Sub Update_Click()
    
    erw = Sheet2.Cells(1, 1).CurrentRegion.Rows.Count + 1
    
    If Len(Range("E11")) <> 0 Then
    Sheet2.Cells(erw, 1) = Range("E11")
    Sheet2.Cells(erw, 2) = Range("E12")
    Sheet2.Cells(erw, 3) = Range("E13")
    Sheet2.Cells(erw, 4) = Range("E14")
    
    Range("E11") = ""
    Range("E12") = ""
    Range("E13") = ""
    Range("E14") = ""
    
    Else
    MsgBox "You must enter data"
    End If
    
    
    End Sub

    Thursday, August 16, 2018 6:30 AM

All replies

  • Hi,

    As i understanding, i assumed that you want to insert from Sheet2 head? If so, you can do this below: 

     

    Private Sub Update_Click()
    Dim targetRow As Integer
      targetRow = 1
      Do Until IsEmpty(Sheet2.Cells(targetRow, 1).Value)
        targetRow = targetRow + 1
      Loop
     
    If Len(Range("E11")) <> 0 Then
    Sheet2.Cells(targetRow, 1) = Range("E11")
    Sheet2.Cells(targetRow, 2) = Range("E12")
    Sheet2.Cells(targetRow, 3) = Range("E13")
    Sheet2.Cells(targetRow, 4) = Range("E14")
     
    Range("E11") = ""
    Range("E12") = ""
    Range("E13") = ""
    Range("E14") = ""
     
    Else
    MsgBox "You must enter data"
    End If
     
    End Sub

    Hope it helps you.

    Best Regards,

    Simon 


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.


    Thursday, August 16, 2018 2:35 PM
    Moderator
  • Did you resolved your issue? Hope you feedback for this. 

    Best Regards,

    Simon


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Monday, August 20, 2018 2:15 AM
    Moderator