|
参与一下。。。
- Sub ykcbf() '//2024.12.13
- Application.ScreenUpdating = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set d = CreateObject("Scripting.Dictionary")
- Set Sh = ThisWorkbook.Sheets("汇总")
- p = ThisWorkbook.Path & ""
- ReDim brr(1 To 10000, 1 To 100)
- For Each fd In fso.GetFolder(p).SubFolders
- For Each f In fso.GetFolder(fd).Files
- Set wb = Workbooks.Open(f, 0)
- arr = wb.Sheets("Sheet1").UsedRange
- wb.Close 0
- For i = 2 To UBound(arr)
- If arr(i, 2) <> Empty Then
- s = arr(i, 2)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = CDate(s)
- brr(m, 4) = 1
- brr(m, 5) = arr(i, 3)
- Else
- r = d(s)
- brr(r, 4) = brr(r, 4) + 1
- brr(r, 5) = brr(r, 5) + arr(i, 3)
- End If
- End If
- Next
- Next
- Next
- With Sh
- .UsedRange.Offset(3).ClearContents
- .[a4].Resize(m, 5) = brr
- .[a4].Resize(m, 5).Borders.LineStyle = 1
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|