|
排重求和。- Sub ykcbf() '//2024.6.24
- Dim arr, d
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1")
- r = .Cells(.Rows.Count, "a").End(xlUp).Row
- arr = .[a1].Resize(r, 26)
- End With
- ReDim brr(1 To UBound(arr), 1 To 3)
- On Error Resume Next
- For i = 2 To UBound(arr) - 2
- rq = Split(arr(i, 1))(0)
- s = rq & "|" & arr(i, 2)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = rq
- brr(m, 2) = arr(i, 2)
- brr(m, 3) = arr(i, 17)
- Else
- r = d(s)
- brr(r, 3) = brr(r, 3) + arr(i, 17)
- End If
- Next
- With Sheets("Sheet2")
- .UsedRange.Offset(1).Clear
- With .[a2].Resize(m, 3)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- .[a2].Resize(m, 3).Sort .[a2], 1
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|