下面是在 VBA 中写出查找并复制的代码:
Sub CopyRows()
Dim i As Long, lastRow1 As Long, lastRow2 As Long
Dim name1 As String, name2 As String
' 获取 sheet1 和 sheet2 中的最后一行
lastRow1 = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
lastRow2 = Sheet2.Range("A" & Rows.Count).End(xlUp).Row