|
楼主 |
发表于 2017-8-23 14:12
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub total()
Application.ScreenUpdating = False
Set d = CreateObject("Scripting.Dictionary")
For Each sh In Sheets
If sh.Name <> ActiveSheet.Name Then
With sh
r = .Cells(Rows.Count, 1).End(3).Row
arr = .[a1].Resize(r, 2)
For i = 2 To UBound(arr)
d(arr(i, 1)) = d(arr(i, 1)) + arr(i, 2)
Next
End With
End If
Next
r = Cells(Rows.Count, 1).End(3).Row
brr = [a2].Resize(r - 1, 2)
For i = 1 To UBound(brr)
If d.exists(brr(i, 1)) Then brr(i, 2) = d(brr(i, 1))
Next
[b2:b10000].ClearContents
[a2].Resize(UBound(brr), UBound(brr, 2)) = brr
Application.ScreenUpdating = True
End Sub
|
|