|
闲着也没事 帮你写写玩玩
仅供参考
- Sub test()
- Dim arr, brr(1 To 1000, 1 To 5)
- Set d = CreateObject("scripting.dictionary")
- Application.DisplayAlerts = False
- With Worksheets("原数据表")
- rw = .[a65536].End(xlUp).Row
- arr = .Range("a4:e" & rw)
- For i = 1 To UBound(arr)
- mx = arr(i, 1) & "*" & arr(i, 3)
- If Not d.exists(mx) Then
- n = n + 1
- d(mx) = n
- For j = 1 To 5
- brr(n, j) = arr(i, j)
- Next
- Else
- m = d(mx)
- brr(m, 2) = brr(m, 2) + arr(i, 2)
- brr(m, 4) = brr(m, 4) + arr(i, 4)
- brr(m, 5) = brr(m, 5) & " " & arr(i, 5)
- End If
- Next
- .[h17].Resize(UBound(brr), 5) = brr
- For i = 17 To .[h65536].End(3).Row
- For x = i + 1 To .[h65536].End(3).Row
- If .Cells(x, 8) = .Cells(i, 8) Then
- .Range(.Cells(i, 8), .Cells(x, 8)).Merge
- End If
- Next
- Next
- End With
- Application.DisplayAlerts = True
- MsgBox "OK"
- End Sub
复制代码
|
|