|
以销售订单作为字典的KEY,并将相同KEY的对应项“数量"、“投产”、“报废”相加,但运行以下宏未实现此项要求
请各位大侠帮帮忙,万分感谢!
Sub 订单查询()
lastrow = Sheets("订单").Cells(65536, 1).End(xlUp).Row
On Error Resume Next
ar = Sheets("订单").Range("A1:AB" & lastrow)
Dim d As New dictionary, k, t
ReDim br(1 To UBound(ar), 1 To 12)
For i = 7 To UBound(ar)
If ar(i, 4) Like "*-0-*" Then
If Not d.Exists(ar(i, 3)) Then
m = m + 1
d(ar(i, 3)) = m
br(m, 1) = m
br(m, 2) = ar(i, 3)
br(m, 3) = ar(i, 5)
br(m, 4) = ar(i, 8)
br(m, 5) = ar(i, 23)
br(m, 6) = ar(i, 24)
br(m, 7) = ar(i, 25)
br(m, 8) = ar(i, 21)
br(m, 9) = ar(i, 19)
br(m, 10) = ar(i, 20)
br(m, 11) = ar(i, 22)
' Else
' br(d(ar(i, 3)), 8) = br(d(ar(i, 3)), 8) + ar(i, 21)
' br(d(ar(i, 3)), 9) = br(d(ar(i, 3)), 9) + ar(i, 19)
' br(d(ar(i, 3)), 10) = br(d(ar(i, 3)), 10) + ar(i, 20)
' br(d(ar(i, 3)), 11) = br(d(ar(i, 3)), 11) + ar(i, 22)
End If
End If
Next
Sheets("T").[A2].Resize(m, 11) = br
Sheets("T").Select
End Sub
|
|