|
把工作表改成数组了,你试下,不过还是前面一个问题要弄清楚,你以哪个订单为准,不然前面的会被后面的覆盖
Sub CopyData()
Dim sheet1 As Worksheet
Dim sheet2 As Worksheet
Dim lastRow1 As Long
Dim lastRow2 As Long
Dim i As Long
Dim j As Long
Set sheet1 = ThisWorkbook.Sheets("采购订单")
Set sheet2 = ThisWorkbook.Sheets("收货单")
arr1 = sheet1.[a1].CurrentRegion
arr2 = sheet2.[a2].CurrentRegion
For i = 2 To UBound(arr1)
For j = 2 To UBound(arr2)
If arr1(i, 3) = arr2(j, 12) Then
arr2(j, 13) = arr1(i, 2)
arr2(j, 14) = arr1(i, 6)
End If
Next j
Next i
sheet2.[a1].Resize(UBound(arr2, 1), UBound(arr2, 2)) = arr2
Set sheet1 = Nothing
Set sheet2 = Nothing
End Sub |
评分
-
1
查看全部评分
-
|