|
参与一下。。。- Sub ykcbf() '//2024.2.13
- Application.ScreenUpdating = False
- Dim arr, brr(1 To 10000, 1 To 20), d, i, m, c, col
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = Sheets("汇总")
- c = 1
- m = 1: brr(1, 1) = "姓名"
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- c = c + 1
- brr(1, c) = CStr(sht.Name)
- With sht
- arr = .UsedRange
- col = Application.Match("应发合计", .Rows(3), 0)
- For i = 5 To UBound(arr)
- s = arr(i, 2)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s '//姓名排重
- End If
- brr(d(s), c) = brr(d(s), c) + arr(i, col)
- Next
- End With
- End If
- Next
- brr(1, c + 1) = "合计"
- With sh
- .UsedRange.Clear
- With .[A1].Resize(m, c + 1)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- r = .Cells(Rows.Count, 1).End(3).Row
- For i = 2 To r
- .Cells(i, c + 1).FormulaR1C1 = "=SUM(RC[-" & c - 1 & "]:RC[-1])"
- Next
- With .Range(.Cells(2, c + 1), .Cells(r, c + 1))
- .HorizontalAlignment = xlRight
- .VerticalAlignment = xlCenter
- End With
- ActiveWindow.DisplayZeros = False
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|