|
参与一下。。。
- Sub ykcbf() '//2024.7.28
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- ReDim brr(1 To UBound(arr), 1 To 100)
- m = 1: n = 3
- brr(1, 1) = "序号"
- brr(1, 2) = arr(1, 3)
- brr(1, 3) = arr(1, 4)
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 1) & "|" & arr(i, 2) & "|" & arr(i, 3) & "|" & arr(i, 4)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = m - 1
- brr(m, 2) = arr(i, 1) & arr(i, 2) & arr(i, 3)
- brr(m, 3) = arr(i, 4)
- End If
- r = d(arr(i, 1) & "|" & arr(i, 2) & "|" & arr(i, 3) & "|" & arr(i, 4))
- s = arr(i, 5)
- If Not d.exists(s) Then
- n = n + 1
- d(s) = n
- brr(1, n) = arr(i, 5)
- End If
- c = d(arr(i, 5))
- brr(r, c) = brr(r, c) + arr(i, 6)
- Next
- With Sheets("Sheet2")
- .UsedRange.Clear
- .[a1].Resize(1, n).Interior.Color = 49407
- With .[a1].Resize(m, n)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Set d = Nothing
- Application.ScreenUpdating = False
- MsgBox "OK!"
- End Sub
复制代码
|
|