|
加个合计行- Sub ykcbf() '//2024.8.9 保教退费汇总,加个合计行
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Dim tm: tm = Timer
- Set sh = ThisWorkbook.Sheets(1)
- p = ThisWorkbook.Path & ""
- ReDim brr(1 To 10000, 1 To 17)
- On Error Resume Next
- For Each f In fso.GetFolder(p).Files
- If LCase$(f.Name) Like "*保教退费*.xls*" Then
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = fso.GetBaseName(f)
- yf = Val(fn)
- n = 2 + yf
- Set wb = Workbooks.Open(f, 0)
- For Each sht In wb.Sheets
- With sht
- arr = .UsedRange.Value
- Set Rng = .UsedRange.Find("序号")
- bt = Rng.Row
- For i = bt + 1 To UBound(arr)
- If Val(arr(i, 4)) > 0 Then
- s = arr(i, 2)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = m
- brr(m, 2) = s
- End If
- r = d(arr(i, 2))
- brr(r, n) = brr(r, n) + Val(arr(i, 4))
- End If
- Next
- End With
- Next
- wb.Close False
- End If
- End If
- Next f
- With sh
- bt = 3
- .UsedRange.Offset(bt).Clear
- With .Cells(bt + 1, 1).Resize(m, 17)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- For i = bt + 1 To m + bt
- .Cells(i, 15) = Application.Sum(.Cells(i, 3).Resize(, 12))
- Next
- .Cells(bt + 1, 2).Resize(m, 14).Sort .Cells(bt + 1, 2), 1
- For j = 3 To 15
- .Cells(bt, j) = Application.Sum(.Cells(bt + 1, j).Resize(m))
- Next
- .UsedRange.Offset(m + bt).Clear
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|