|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("本批发货 2")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Range("j2:m" & r).ClearContents
- arr = .Range("a2:n" & r)
- For i = 1 To UBound(arr)
- xm = arr(i, 1) & "+" & arr(i, 2) & "+" & arr(i, 5)
- If Not d.exists(xm) Then
- ReDim brr(1 To 2)
- brr(1) = i
- Else
- brr = d(xm)
- End If
- brr(2) = brr(2) + arr(i, 4)
- d(xm) = brr
- Next
- For Each aa In d.keys
- brr = d(aa)
- m = brr(1)
- arr(m, 10) = Int(brr(2) / arr(m, 9))
- arr(m, 11) = brr(2) Mod arr(m, 9)
- If Len(arr(m, 11)) <> 0 Then
- arr(m, 12) = arr(m, 10) + 1
- Else
- arr(m, 12) = arr(m, 10)
- End If
- arr(m, 13) = arr(m, 12)
- Next
- .Range("a2").Resize(UBound(arr), UBound(arr, 2)) = arr
- End With
- End Sub
复制代码 |
|