Sub 保存订单()
Dim arr, brr(), d As Object, r%, i&, j%, m&, s$
Set d = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
r = Range("a65536").End(3).Row
arr = Range("b5:m" & r)
ReDim brr(1 To 2000, 1 To 15)
For i = 1 To UBound(arr)
s = arr(i, 1) & arr(i, 2) & arr(i, 3)
If d.exists(s) Then
r = d(s)
brr(r, 6) = brr(r, 6) + arr(i, 6)
brr(r, 10) = brr(r, 10) + arr(i, 9)
brr(r, 11) = brr(r, 11) + arr(i, 10)
Else
If arr(i, 1) <> "" Then
m = m + 1
d(s) = m
For j = 1 To 7
brr(m, j) = arr(i, j)
Next
brr(m, 8) = Range("c2") '供应商
brr(m, 9) = arr(i, 8) '单价
brr(m, 10) = arr(i, 9) '金额
brr(m, 11) = arr(i, 10) '运费
brr(m, 12) = Range("k2") '订货日期
brr(m, 13) = Range("k3") '交货日期
brr(m, 14) = "" '对应项不清
brr(m, 15) = Range("k3") '订单号
End If
End If
Next
Set d = Nothing
With Sheets("订货汇总")
.[a1].CurrentRegion.Offset(1).ClearContents
.[a2].Resize(m, 15) = brr
.[a2].Resize(m, 15).Borders.LineStyle = xlContinuous '添总体加边框线
.[a2].Resize(m, 15).BorderAround xlContinuous, xlMedium '外边框加粗
.[a2].Resize(m, 15).Font.Size = 10 '字体10号
End With
Application.ScreenUpdating = True
MsgBox "OK!已完成汇总!"
End Sub
|