|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 汇总()
Application.ScreenUpdating = False
Dim ar As Variant
Dim i As Long, r As Long, rs As Long
Dim brr()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("sheet1")
rs = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:b" & rs)
ReDim brr(1 To UBound(ar), 1 To 2)
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
brr(k, 1) = ar(i, 1)
End If
brr(t, 2) = brr(t, 2) + ar(i, 2)
End If
Next i
.[e1].Resize(1, 2) = Array("月份", "金额")
.[e2].Resize(k, 2) = brr
End With
MsgBox "ok!"
End Sub
|
|