|
Sub 求和()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("到货单列表")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "到货单列表为空!": End
br = .Range("a1:k" & r)
End With
With Sheets("请购明细")
rs = .Cells(Rows.Count, 1).End(xlUp).Row
If rs < 2 Then MsgBox "请购明细为空!": End
.Range("s3:aq" & rs) = Empty
ar = .Range("a2:aq" & rs)
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" And Trim(ar(i, 11)) <> "" Then
zd = Trim(ar(i, 2)) & "|" & Trim(ar(i, 11))
d(zd) = i
End If
Next i
For j = 19 To UBound(ar, 2)
d(ar(1, j)) = j
Next j
For i = 2 To UBound(br)
zd = Trim(br(i, 7)) & "|" & Trim(br(i, 3))
xh = d(zd)
lh = d(br(i, 5))
If xh <> "" And lh <> "" Then
ar(xh, lh) = ar(xh, lh) + br(i, 11)
End If
Next i
For j = 19 To UBound(ar, 2)
.Cells(2, j).Resize(UBound(ar), 1) = Application.Index(ar, 0, j)
Next j
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|