|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub 汇总()
Dim i, k, name
Dim w As Worksheet, r As Worksheets
Set r = Worksheets("季度汇总")
For i = 3 To 10
name = r.Cells(i, 2)
For Each w In Worksheets
If Right(w.name, 1) = "月" Then
k = 3
Do While w.Cells(k, 2) <> ""
If LCase(Trim(w.Cells(k, 2))) = LCase(Trim(name)) Then
r.Cells(i, 3) = r.Cells(i, 3) + w.Cells(k, 3)
r.Cells(i, 4) = r.Cells(i, 4) + w.Cells(k, 4)
r.Cells(i, 5) = r.Cells(i, 5) + w.Cells(k, 5)
r.Cells(i, 6) = r.Cells(i, 6) + w.Cells(k, 6)
End If
k = k + 1
Loop
End If
Next w
Next i
End Sub
|
|