|

楼主 |
发表于 2017-8-23 14:12
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
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
|
|