|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Dim i As Integer, j As Integer
Dim ar1 As Variant
ar1 = Sheets("Sheet2").[a1048576].End(xlUp).Row
arr1 = Sheets("Sheet2").Range("A1:h" & Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row)
arr2 = Sheets("Sheet1").Range("a2:h" & Sheets("Sheet1").Cells(Rows.Count, "a").End(xlUp).Row)
For i = 1 To UBound(arr1)
For j = 1 To UBound(arr2)
If arr1(i, 1) = arr2(j, 1) Then
arr1(i, 2) = arr2(j, 2)
arr1(i, 3) = arr2(j, 3)
arr1(i, 4) = arr2(j, 4)
arr1(i, 5) = arr2(j, 5)
arr1(i, 6) = arr2(j, 6)
arr1(i, 7) = arr2(j, 7)
arr1(i, 8) = arr2(j, 8)
GoTo ar1
End If
ar1:
Next
Next
Sheets("Sheet2").Range("A1:h" & Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row) = arr1
End Sub
|
|