|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。- Sub ykcbf() '//2024.1.19
- Dim arr, brr, d
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("汇总")
- col = 3 '//汇总列号
- For Each sht In Sheets
- If Val(sht.Name) Then
- With sht
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a5:d" & r)
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If Not d.exists(s) Then
- d(s) = Array(s, Val(arr(i, col)))
- Else
- t = d(s)
- t(1) = t(1) + Val(arr(i, col))
- d(s) = t
- End If
- Next
- End With
- End If
- Next
- With sh
- .UsedRange.Offset(1).Clear
- With .[a2].Resize(d.Count, 2)
- .Value = Application.Rept(d.Items, 1)
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
|