|
参与一下。。。
- Sub ykcbf() '//2024.12.7
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("总表")
- ReDim brr(1 To 10000, 1 To 100)
- m = 1: n = 3
- On Error Resume Next
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- n = n + 1
- With sht
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 3)
- brr(1, n) = arr(1, 1)
- End With
- If n = 4 Then
- For j = 1 To 3
- brr(1, j) = arr(2, j)
- Next
- End If
- For i = 3 To UBound(arr)
- s = arr(i, 1)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = arr(i, 1)
- brr(m, 2) = arr(i, 2)
- End If
- r = d(arr(i, 1))
- brr(r, n) = brr(r, n) + arr(i, 3)
- Next
- End If
- Next
- With sh
- .UsedRange.Clear
- .Cells.Interior.ColorIndex = 0
- .[a1].Resize(1, n).Interior.Color = 49407
- .[a2].Resize(m - 1, 1).Interior.Color = 5296274
- With .[a1].Resize(m, n)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- End With
- End With
- For i = 2 To m
- .Cells(i, 3).Value = Application.Sum(.Cells(i, 3).Resize(, n - 2))
- Next
- .[c2].Resize(m - 1, n - 2).HorizontalAlignment = xlRight
- .[c2].Resize(m - 1, n - 2).NumberFormatLocal = "0.00"
- .Columns(3).NumberFormatLocal = "0"
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|