|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("原版")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:h" & r)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then
- d(arr(i, 1)) = i
- Else
- m = d(arr(i, 1))
- If InStr(arr(m, 4), arr(i, 1)) = 0 Then
- arr(m, 4) = arr(m, 4) & "/" & arr(i, 4)
- End If
- For j = 6 To 8
- arr(m, j) = arr(m, j) + arr(i, j)
- Next
- End If
- Next
- End With
- ReDim brr(1 To d.Count, 1 To UBound(arr, 2))
- m = 0
- For Each aa In d.items
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(aa, j)
- Next
- Next
- With Worksheets("目标")
- .UsedRange.Offset(1, 0).ClearContents
- .Range("a2").Resize(UBound(brr), UBound(brr, 2)) = brr
- End With
- End Sub
复制代码 |
|