|
Sub 汇总()
Application.ScreenUpdating = False
Dim d As Object
Dim ar As Variant, br As Variant
Dim i As Long
Dim arr()
Set d = CreateObject("scripting.dictionary")
br = Sheets("库存表").[a1].CurrentRegion
With Sheets("产品查找")
.[a1].CurrentRegion.Offset(1, 7) = Empty
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .[a1].CurrentRegion
For i = 2 To UBound(ar)
If Trim(ar(i, 4)) <> "" Then
d(Trim(ar(i, 4))) = i
End If
Next i
For i = 2 To UBound(br)
If Trim(br(i, 4)) <> "" Then
xh = d(Trim(br(i, 4)))
If xh <> "" Then
m = .Cells(xh, Columns.Count).End(xlToLeft).Column + 1
.Cells(xh, m) = br(i, 1)
.Cells(xh, m + 1) = br(i, 2)
.Cells(xh, m + 2) = br(i, 5)
.Cells(xh, m + 3) = br(i, 6)
.Cells(xh, m + 4) = br(i, 7)
End If
End If
Next i
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|