|
Sub 匹配()
Application.ScreenUpdating = False
Dim ar As Variant, br As Variant
Dim i As Long, r As Long, rs As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("入库信息")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:h" & r)
End With
For i = 2 To UBound(ar)
If Trim(ar(i, 4)) <> "" Then
If Not d.exists(Trim(ar(i, 4))) Then
d(Trim(ar(i, 4))) = ar(i, 3)
Else
d(Trim(ar(i, 4))) = d(Trim(ar(i, 4))) & "|" & ar(i, 3)
End If
End If
Next i
With Sheets("合同量内表")
rs = .Cells(Rows.Count, 2).End(xlUp).Row
.[a1].CurrentRegion.Offset(1, 17) = Empty
br = .Range("b1:b" & rs)
For i = 2 To UBound(br)
y = 17
If Trim(br(i, 1)) <> "" Then
If d.exists(Trim(br(i, 1))) Then
zd = d(Trim(br(i, 1)))
If InStr(zd, "|") = 0 Then
.Cells(i, 18) = zd
Else
rr = Split(zd, "|")
For s = 0 To UBound(rr)
y = y + 1
.Cells(i, y) = rr(s)
Next s
End If
End If
End If
Next i
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|