VBA复制最后一行范围并粘贴到另一张表

时间:2016-10-17 11:18:22

标签: vba spreadsheet copy-paste

我正在尝试找到列的最后一个单元格,例如然后复制整个行范围,该行范围对应于该单元格,例如复制A5,B5,C5等并将它们粘贴到特定行范围内的另一张纸上,例如A10,B10,C10等有什么帮助吗?非常感谢你!

Sub Macro3() 
  Sheets("Stream").Range("D" & Rows.Count).End(xlUp).Copy
  Sheets("General").Range("F2").PasteSpecial Paste:=xlPasteValues,   Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End Sub

1 个答案:

答案 0 :(得分:0)

Sub Macro3() 
        Dim LastRowStream As Long, LastRowGeneral As Long,
        LastRowStream = Sheets("Stream").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        Rows(LastRowStream & ":" & LastRowStream).EntireRow.copy

        LastRowGeneral = Sheets("General").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        Sheets("General").Range("A" & LastRowGeneral).PasteSpecial Paste:=xlPasteValues,   Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End Sub