|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
改一下。。。- Sub ykcbf() '//2024.12.23
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("总表")
- ReDim brr(1 To 100000, 1 To 100)
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- If sht.UsedRange.Count > 1 Then
- arr = sht.UsedRange
- r = sht.Columns(1).Find("合计").Row
- For j = 4 To UBound(arr, 2) Step 3
- For i = 3 To r - 3
- If arr(i, j + 1) <> Empty Then
- s = arr(i, 1)
- If Not d.exists(s) Then
- d(s) = Array(arr(i, j), arr(i, j + 1), arr(i, j + 2))
- Else
- t = d(s)
- t(0) = t(0) + arr(i, j)
- t(1) = t(1) + arr(i, j + 1)
- t(2) = t(2) + arr(i, j + 2)
- d(s) = t
- End If
- End If
- Next
- Next
- End If
- End If
- Next
- With sh
- .UsedRange.Offset(2, 4).ClearContents
- arr = .UsedRange
- For i = 3 To UBound(arr)
- s = arr(i, 1)
- If d.exists(s) Then
- For j = 5 To 7
- arr(i, j) = d(s)(j - 5)
- Next
- End If
- Next
- .UsedRange = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|