|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 Zamyi 于 2011-8-26 11:11 编辑
第5个改下更好,增加字典,对第项一次统计:
Sub breezy_method_5()
Dim aw
Dim i&, aCount&, iRow$, s1&, s2$
aCount = 0
s1 = 2006
s2 = "A"
iRow = Range("A65536").End(xlUp).Row
aw = Cells(2, 1).Resize(iRow - 1, 3)
For i = 1 To iRow - 1
If aw(i, 1) = s1 then if aw(i, 2) = s2 Then aCount = aCount + aw(i, 3)
Next i
Range("E9") = aCount
End Sub
Sub zd()
Set d = CreateObject("scripting.dictionary")
r = Range("c3", [a65536].End(3))
For i = 1 To UBound(r)
s = r(i, 1) & r(i, 2)
d(s) = d(s) + r(i, 3)
Next
Range("E10") = d("2006A")
Set d = Nothing
End Sub |
|