|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。- Sub ykcbf() '//2024.1.25
- Dim arr, brr, d
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a1:g" & r)
- For i = 2 To UBound(arr)
- s = arr(i, 2)
- If Not d.exists(s) Then
- d(s) = Array(1, arr(i, 4), arr(i, 5), arr(i, 6), arr(i, 7))
- Else
- t = d(s)
- t(0) = t(0) + 1
- For x = 1 To 4
- t(x) = t(x) + arr(i, x + 3)
- Next
- d(s) = t
- End If
- Next
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- For Each k In d.keys
- m = m + 1
- brr(m, 1) = k
- brr(m, 2) = d(k)(0)
- brr(m, 3) = d(k)(4) / d(k)(0)
- For x = 1 To 4
- brr(m, x + 3) = d(k)(x)
- Next
- Next
- .[j3:p1000] = ""
- .[j3].Resize(m, 7) = brr
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|