|
Sub 数据匹配()
Application.ScreenUpdating = False
Dim d As Object
Dim ar As Variant, br As Variant
Set d = CreateObject("scripting.dictionary")
f = Dir(ThisWorkbook.Path & "\工单印刷资料明细2016-2020.xls*")
If f = "" Then MsgBox "找不到工单印刷资料明细2016-2020文件": Exit Sub
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
br = wb.Worksheets(1).[a1].CurrentRegion
For i = 2 To UBound(br)
If Trim(br(i, 1)) <> "" Then
d(Trim(br(i, 1))) = i
End If
Next i
wb.Close False
With Sheets("产品入库明细表2020")
r = .Cells(Rows.Count, 1).End(xlUp).Row
.Range("ag2:ag" & r) = Empty
.Range("aj2:aj" & r) = Empty
ar = .[a1].CurrentRegion
For i = 2 To UBound(ar)
If Trim(ar(i, 5)) <> "" Then
n = d(Trim(ar(i, 5)))
If n <> "" Then
ar(i, 33) = br(n, 7)
ar(i, 36) = br(n, 15)
End If
End If
Next i
.[a1].CurrentRegion = ar
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|