|
按实际改一下。
- Sub ykcbf() '//2024.9.9
- Application.ScreenUpdating = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- p = ThisWorkbook.Path & ""
- Set sh = ThisWorkbook.Sheets("总表")
- ReDim brr(1 To 10000, 1 To 500)
- For Each fd In fso.GetFolder(p).SubFolders
- For Each f In fd.Files
- If LCase(f.Name) Like "*.csv" Then
- Set wb = Workbooks.Open(f, 0)
- n = n + 1
- With wb.Sheets(1)
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .Cells(1, "XFD").End(1).Column
- arr = .[a1].Resize(r, c)
- End With
- wb.Close 0
- For i = IIf(n = 1, 1, 2) To UBound(arr)
- M = M + 1
- For j = 1 To UBound(arr, 2)
- If arr(i, 1) <> Empty Then brr(M, j) = arr(i, j)
- Next
- Next
- End If
- Next
- Next
- With sh
- .UsedRange.Clear
- .[a1].Resize(1, c).Interior.Color = 49407
- With .[a1].Resize(M, c)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|