|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 汇总()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Dim ar As Variant, br As Variant
Dim sh As Worksheet
ReDim br(1 To 10000, 1 To 3)
For Each sh In Sheets
If sh.Name <> "全年汇总" Then
ar = sh.[a1].CurrentRegion
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
t = d(Trim(ar(i, 1)))
If t = "" Then
k = k + 1
d(Trim(ar(i, 1))) = k
t = k
br(k, 1) = ar(i, 1)
End If
br(t, 2) = br(t, 2) + ar(i, 2)
br(t, 3) = br(t, 3) + ar(i, 3)
End If
Next i
End If
Next sh
With Sheets("全年汇总")
.[a1].CurrentRegion.Offset(1) = Empty
.[a2].Resize(k, 3) = br
End With
MsgBox "ok!"
End Sub
|
|