- Sub mytest1()
- Dim d%, ar, x%, m%, y%, n%, j%
- d = Sheets("汇总").Range("a3:z3").Find("小计").Column
- Sheets("汇总").Range(Cells(4, 2), Cells(15, d - 1)).ClearContents
- ar = Sheets("汇总").Range(Cells(4, 1), Cells(15, d - 1))
- For x = 2 To d - 1
- For m = 1 To UBound(ar)
- For y = 2 To Worksheets.Count
- If Sheets("汇总").Cells(3, x) = Sheets(y).Name Then
- For n = 4 To Sheets(y).Range("g60000").End(3).Row
- If Month(Sheets(y).Cells(n, 9)) = Month(ar(m, 1)) And _
- Sheets(y).Cells(n, 9) <> "" Then
- ar(m, x) = ar(m, x) + Sheets(y).Cells(n, 7)
- End If
- Next n
- End If
- Next y
- Next m
- Next x
- Sheets("汇总").Range("a4").Resize(UBound(ar, 1), UBound(ar, 2)) = ar
- End Sub
复制代码 |