|
hxzang 发表于 2015-1-22 16:54
是的,谢谢!
请测试》》》- Sub total()
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- r = Cells.Find("*", Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row '计算最后一个工作表的非空行号
- arr = [a2].Resize(r - 1, 5)
- For i = 1 To UBound(arr)
- d(Val(arr(i, 1))) = Val(arr(i, 3))
- Next i
- d1(0) = d(0)
- For i = 2 To d.Count
- d1(i - 1) = d(i - 1) * d1(i - 2)
- Next
- s1 = d.items
- s2 = d1.items
- For i = 1 To UBound(arr)
- If Val(arr(i, 1)) = 0 Then
- arr(i, 5) = arr(i, 3)
- Else
- arr(i, 5) = arr(i, 3) * d1(Val(arr(i, 1)) - 1)
- End If
- Next i
- [a2].Resize(r - 1, 5) = arr
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|