|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。- Sub ykcbf() '//2024.1.4
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("汇总1-12")
- On Error Resume Next
- For Each sht In Sheets
- With sht
- If .UsedRange.Count > 1 Then
- arr = .UsedRange
- For j = 1 To UBound(arr, 2)
- If arr(i, 1) <> Empty Then
- s = arr(1, j)
- d1(s) = s
- End If
- Next
- For i = 2 To UBound(arr)
- s = arr(i, 2)
- If s <> Empty Then
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- For j = 1 To UBound(arr, 2)
- ss = arr(1, j)
- d(s)(ss) = d(s)(ss) + arr(i, j)
- Next
- End If
- Next
- End If
- End With
- Next
- ReDim zrr(1 To d.Count, 1 To 2)
- For Each k In d.keys
- n = n + 1
- zrr(n, 1) = n
- zrr(n, 2) = k
- Next
- With sh
- .UsedRange = ""
- .[a1].Resize(1, d1.Count) = d1.keys
- .[a2].Resize(n, 2) = zrr
- arr = .UsedRange
- For i = 2 To UBound(arr)
- If arr(i, 1) <> Empty Then
- For j = 3 To UBound(arr, 2)
- If d.exists(arr(i, 2)) Then
- arr(i, j) = d(arr(i, 2))(arr(1, j))
- End If
- Next
- End If
- Next
- .UsedRange = arr
- ActiveWindow.DisplayZeros = False
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|