|
伙食退费汇总。。。- Sub ykcbf() '//2024.8.8 伙食退费汇总
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Dim tm: tm = Timer
- Set sh = ThisWorkbook.Sheets("伙食汇总")
- 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
- .UsedRange.Offset(2).Clear
- With .[a3].Resize(m, 17)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- For i = 3 To m + 2
- .Cells(i, 15) = Application.Sum(.Cells(i, 3).Resize(, 12))
- Next
- .[b3].Resize(m, 14).Sort .[b3], 1
- .UsedRange.Offset(m + 2).Clear
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|