|
- Public Sub test()
- Application.ScreenUpdating = False
- Dim r, d(), i As Long, j As Long, s As String, q
- arr = Sheet1.[a1].CurrentRegion
- ReDim d(1 To UBound(arr, 2) - 6)
- For j = 1 To UBound(arr, 2) - 6
- Set d(j) = CreateObject("scripting.dictionary")
- Next
- For j = 1 To UBound(arr, 2) - 6
- For i = 1 To UBound(arr)
- s = arr(i, 2) & "," & arr(i, 3) & "," & arr(i, 4) & "," & arr(i, 5) & "," & arr(i, 6)
- d(j)(s) = d(j)(s) + arr(i, j + 6)
- Next
- Next
- r = d(1).keys
- For i = 1 To d(1).Count
- q = Split(r(i - 1), ",")
- Cells(i, 1).Resize(, 5) = q
- Next
- For j = 1 To UBound(arr, 2) - 6
- Cells(1, j + 5).Resize(d(j).Count, 1) = Application.Transpose(d(j).items)
- Next
- Erase d, arr, r, q
- Application.ScreenUpdating = True
- MsgBox "整理完成!"
- End Sub
复制代码 |
|