|
关于我在2楼的疑问,你貌似一个字都没有回答清楚,请别人帮助好歹把问题说的清楚点。以后看到这种描述不清楚的问题,都懒得提醒”你问题描述不清晰“了。- Sub 汇总()
- Dim Arr, Brr, d1, d2, d3, drow%, i%, j%
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- Set d3 = CreateObject("scripting.dictionary")
- With Worksheets("基本资料")
- drow = .[a65536].End(3).Row
- Arr = .Range("a2:i" & drow)
- For i = 1 To UBound(Arr)
- Arr(i, 8) = Arr(i, 4) - Arr(i, 6)
- Arr(i, 9) = CStr(Year(Arr(i, 1))) & CStr(Month(Arr(i, 1)))
- d1(Arr(i, 9)) = d1(Arr(i, 9)) + Arr(i, 4)
- d2(Arr(i, 9)) = d2(Arr(i, 9)) + Arr(i, 6)
- d3(Arr(i, 9)) = d3(Arr(i, 9)) + Arr(i, 8)
- Next
- .[a20].Resize(UBound(Arr), UBound(Arr, 2)) = Arr
- End With
- With Worksheets("数据汇总表")
- .Range("a3:h65536").ClearContents
- .[a3].Resize(d1.Count, 1) = Application.Transpose(d1.keys)
- [c3].Resize(d1.Count, 1) = Application.Transpose(d1.items)
- [e3].Resize(d2.Count, 1) = Application.Transpose(d2.items)
- [h3].Resize(d3.Count, 1) = Application.Transpose(d3.items)
- End With
- MsgBox "汇总完毕"
- End Sub
复制代码 |
|