|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 分类汇总()
Dim d As Object
Dim brr()
Set d = CreateObject("scripting.dictionary")
arr = ThisWorkbook.Worksheets("1月").Range("b2:aw2")
Set Rng = ThisWorkbook.Worksheets("1月").Range("a2:a82")
Application.SheetsInNewWorkbook = 1
Set wb = Workbooks.Add
For j = 1 To UBound(arr, 2)
If InStr(arr(1, j), "合计") = 0 Then
y = 1: n = 2
ReDim brr(1 To 81, 1 To 13)
For Each sh In ThisWorkbook.Worksheets
If sh.Name <> "1-12月" Then
y = y + 1
brr(1, y) = sh.Name
ar = sh.[a1].CurrentRegion
lh = sh.Rows(2).Find(arr(1, j), , , 1).Column
For i = 3 To 82
brr(i - 1, 1) = ar(i, 1)
brr(i - 1, y) = brr(i - 1, y) + ar(i, lh)
Next i
End If
Next sh
Set sht = Worksheets.Add(after:=wb.Worksheets(wb.Worksheets.Count))
sht.Name = arr(1, j)
sht.[a1].Resize(UBound(brr), UBound(brr, 2)) = brr
End If
Next j
wb.SaveAs Filename:=ThisWorkbook.Path & "\汇总表.xlsx"
wb.Close
End Sub
|
|