Copy data from one sheet to the last row of another sheet

前端 未结 2 1847
耶瑟儿~
耶瑟儿~ 2021-01-27 23:50

I\'m trying to copy the data from one sheet to the last row of another sheet.

The reason why I am doing this is because I want to consolidate the data in a sheet which

相关标签:
2条回答
  • 2021-01-28 00:26

    Would this work for you. defining srcLastRow as below.

    srcLastRow = Cells(Rows.Count, 36).End(xlUp).Row

    0 讨论(0)
  • 2021-01-28 00:33

    You know your copied range, so then you need to know the last row of the destination sheet:

    dim lr as long
    With Sheets("Destination")
        lr = .cells(.rows.count,1).end(xlup).row 'assumes column 1 is contiguous
    End with
    

    You can then take your source range (will use variable SrcRng) and paste to the new sheet, into a specific cell:

    SrcRng.Copy Sheets("Destination").Cells(lr+1,1) 'this line does the copy and the paste
    

    The rest of the copied range will be filled in.


    Edit1:

    Hard to show the code in a comment...

    Dim LRSrc as Long, LRDest as Long, SrcRng as Range
    With Sheets("Source")
        LRSrc = .cells(.rows.count,1).end(xlup).row 'assumes column 1 is contiguous
        Set SrcRng = .Range("A1:AJ" & LRSrc)
    End with
    With Sheets("Destination")
        LRDest = .cells(.rows.count,1).end(xlup).row 'assumes column 1 is contiguous
        SrcRng.Copy .Cells(LRDest+1,1)
    End with
    
    0 讨论(0)
提交回复
热议问题