|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.8.15
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- With Sheets("测试数据")
- r = .Cells(Rows.Count, "h").End(3).Row
- arr = .[h1].Resize(r, 4)
- End With
- ReDim brr(1 To UBound(arr), 1 To 4)
- For i = 2 To UBound(arr)
- s = arr(i, 1) & "|" & arr(i, 2) & "|" & arr(i, 3)
- 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)
- brr(r, 4) = brr(r, 4) + arr(i, 4)
- End If
- Next
- With Sheets("操作结果")
- .[h2].Resize(10000, 4) = ""
- .Range("h2").Resize(m, 4) = brr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|