|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf() '//2024.8.14 排重汇总
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- p = ThisWorkbook.Path & ""
- Set sh = ThisWorkbook.Sheets("2024奖金发放汇总")
- Set d = CreateObject("Scripting.Dictionary")
- a = [{"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","年终奖"}]
- ReDim brr(1 To 10000, 1 To 100)
- Dim tm: tm = Timer
- p = ThisWorkbook.Path & ""
- 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)
- st = Replace(fn, "份奖金发放表", "")
- yf = Mid(st, 8)
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- wb.Close False
- End With
- For i = 4 To UBound(arr)
- s = arr(i, 2)
- If s <> Empty Then
- 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))
- n = 2
- For x = 1 To UBound(a)
- If yf = a(x) Then
- n = n + x
- Exit For
- End If
- Next
- brr(r, n) = brr(r, n) + arr(i, 4)
- End If
- Next
- End If
- End If
- Next f
- With sh
- .UsedRange.Offset(2).Clear
- .[a2].Resize(1, 15).Interior.Color = 49407
- With .[a3].Resize(m, 15)
- .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(, 13))
- Next
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|