[英]Copying Data from one sheet to the last row of another sheet
I'm trying to make something in Excel work, but I cannot.我正在尝试在 Excel 中做一些事情,但我做不到。 I have 2 Sheets Sheet 1 is the "main sheet" Sheet 2 has a filter.我有 2 张表 表 1 是“主表”表 2 有一个过滤器。 I want 2 filtered columns to be copied to the main sheet and pasted at the end of the already existing content.我希望将 2 个过滤列复制到主工作表并粘贴到现有内容的末尾。
Try this - you will need to update the ranges/sheet names as required.试试这个 - 您需要根据需要更新范围/工作表名称。
Sub CopyDataLastRow()
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim CopyLastRow As Long
Dim DestLastRow As Long
'Set Variables
Set wsCopy = Sheets("Sheet1") 'Update your sheet name as required.
Set wsDest = Sheets("Sheet2") 'Update your sheet name as required.
'Find Last Row in Copy Range
CopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row
'Find 1st blank row in Destination Range - Offset 1 row
DestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
'Copy & Paste Data
wsCopy.Range("A2:B" & CopyLastRow).Copy _
wsDest.Range("A" & DestLastRow)
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.