none
Paste data to the empty cell automatically RRS feed

  • Question

  • Hello

    My name is Rio

    I have a problem

    I have a set of data in workbook ("Checking.xlsx") Sheets ("Summary")

    I want to copy all data from ("A:C") from those sheet and paste it to ThisWorkbook (Current Workbook that contain VBA Code) in Sheets ("Master Customer") in the empty cell --> I want to paste it in the first empty row or empty cells

    Please help me to solve my problem

    Thank you

    Best regards,

    Rio


    riok58

    Tuesday, February 21, 2017 2:04 AM

Answers

  • Sub CopyData()
        Dim wshS As Worksheet ' Source sheet
        Dim wshT As Worksheet ' Target sheet
        Dim lngT As Long      ' First available row on target sheet
        Set wshS = Workbooks("Checking.xlsx").Worksheets("Summary")
        Set wshT = ThisWorkbook.Worksheets("Master Customer")
        lngT = wshT.Cells.Find(What:="*", SearchOrder:=xlByRows, _
            SearchDirection:=xlPrevious).Row + 1
        With wshS
            Intersect(.Range("A:C"), .UsedRange).Copy _
                Destination:=wshT.Range("A" & lngT)
        End With
        Application.CutCopyMode = False
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by riok58 Wednesday, February 22, 2017 1:35 AM
    Tuesday, February 21, 2017 6:50 AM

All replies

  • Sub CopyData()
        Dim wshS As Worksheet ' Source sheet
        Dim wshT As Worksheet ' Target sheet
        Dim lngT As Long      ' First available row on target sheet
        Set wshS = Workbooks("Checking.xlsx").Worksheets("Summary")
        Set wshT = ThisWorkbook.Worksheets("Master Customer")
        lngT = wshT.Cells.Find(What:="*", SearchOrder:=xlByRows, _
            SearchDirection:=xlPrevious).Row + 1
        With wshS
            Intersect(.Range("A:C"), .UsedRange).Copy _
                Destination:=wshT.Range("A" & lngT)
        End With
        Application.CutCopyMode = False
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by riok58 Wednesday, February 22, 2017 1:35 AM
    Tuesday, February 21, 2017 6:50 AM
  • It works perfectly

    Thank you


    riok58

    Wednesday, February 22, 2017 1:36 AM