|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf() '//2024.12.21
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 2).End(3).Row
- c = .Cells(1, "XFD").End(1).Column
- arr = .[a1].Resize(r, c)
- End With
- ReDim brr(1 To 10000, 1 To 100)
- For i = 2 To UBound(arr)
- s = arr(i, 2)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- Else
- r = d(s)
- For j = 4 To UBound(arr, 2)
- brr(r, j) = brr(r, j) + arr(i, j)
- Next
- End If
- Next
- With Sheets("Sheet2")
- .UsedRange.Offset(1).ClearContents
- .[a2].Resize(m, UBound(arr, 2)) = brr
- End With
- Set d = Nothing
- Application.ScreenUpdating = False
- MsgBox "OK!"
- End Sub
复制代码
|
|