|
参与一下。。。
- Sub ykcbf() '//2024.11.15
- 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)
- m = 1: n = 1
- brr(1, 1) = "编号"
- For Each fd In fso.GetFolder(p).SubFolders
- For Each f In fso.GetFolder(fd).Files
- 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)
- End With
- wb.Close 0
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- End If
- r = d(arr(i, 1))
- For j = 2 To UBound(arr, 2)
- s = arr(1, j)
- If Not d.exists(s) Then
- n = n + 1
- d(s) = n
- brr(1, n) = s
- End If
- c = d(arr(1, j))
- brr(r, c) = arr(i, j)
- Next
- Next
- Next
- Next
- With sh
- .UsedRange.Clear
- .[a1].Resize(1, n).Interior.Color = 49407
- .[a1].Resize(1, n).WrapText = True
- With .[a1].Resize(m, n)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Application.ScreenUpdating = True
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|