|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Dim rng As Range
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(1, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a1").Resize(r, c)
- Set rng = .Rows(r + 1)
- For i = 2 To UBound(arr)
- If Not d.exists(arr(i, 4)) Then
- d(arr(i, 4)) = i
- Else
- m = d(arr(i, 4))
- arr(m, 16) = arr(m, 16) + arr(i, 16)
- Set rng = Union(rng, .Rows(i))
- End If
- Next
- .Range("a1").Resize(UBound(arr), UBound(arr, 2)) = arr
- rng.Delete
- End With
- End Sub
复制代码 |
|