|
Sub test()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
Set d3 = CreateObject("scripting.dictionary")
ar = Sheets(2).UsedRange
For r = UBound(ar) To 7 Step -1
d1(ar(r, 3) & ar(r, 11)) = r
d2(ar(r, 3)) = r
d3(ar(r, 3) & ar(r, 8)) = r
Next
br = Sheets(1).UsedRange
For r = 6 To UBound(br)
If d1.exists(br(r, 3) & br(r, 13)) Then br(r, 14) = ar(d1(br(r, 3) & br(r, 13)), 8)
If d2.exists(br(r, 3)) Then br(r, 15) = ar(d2(br(r, 3)), 8)
If d3.exists(br(r, 3) & br(r, 15)) Then br(r, 16) = ar(d3(br(r, 3) & br(r, 15)), 11)
If br(r, 16) <> br(r, 13) Then br(r, 17) = "需核对" Else br(r, 17) = ""
If br(r, 14) = br(r, 15) Then br(r, 17) = ""
Next
Sheets(1).UsedRange = br
Set d1 = Nothing
Set d2 = Nothing
Set d3 = Nothing
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub |
|