|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim ws As Worksheet
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- For Each ws In Worksheets
- If ws.Name Like "*月" Then
- With ws
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:c" & r)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then
- Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
- End If
- If Not d(arr(i, 1)).exists(arr(i, 2)) Then
- ReDim brr(1 To 14)
- brr(1) = arr(i, 1)
- brr(2) = arr(i, 2)
- Else
- brr = d(arr(i, 1))(arr(i, 2))
- End If
- n = Val(ws.Name) + 2
- brr(n) = brr(n) + arr(i, 3)
- d(arr(i, 1))(arr(i, 2)) = brr
- Next
- End With
- End If
- Next
- With Worksheets("汇总")
- .UsedRange.Offset(1, 0).Clear
- m = 1
- For Each aa In d.keys
- For Each bb In d(aa).keys
- m = m + 1
- .Cells(m, 1).Resize(1, UBound(brr)) = d(aa)(bb)
- Next
- Next
- End With
- End Sub
复制代码 |
|