|
重新写一个。。。
- Sub ykcbf() '//2024.8.20
- Set fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- b = Application.Transpose(sh.[p3:y3].Value)
- p = ThisWorkbook.Path & ""
- ReDim brr(1 To 10000, 1 To 100)
- 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)
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("Report")
- r = .Cells(Rows.Count, "aw").End(3).Row
- arr = .[av4].Resize(10, 13)
- For i = 1 To UBound(arr)
- If arr(i, 2) <> Empty Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- brr(m, 14) = fn
- For x = 1 To UBound(b)
- brr(m, x + 14) = .Range(b(x, 1)).Value
- Next
- End If
- Next
- End With
- wb.Close False
- End If
- End If
- Next f
- With sh
- .[a4:z1000].ClearContents
- .Columns("M:N").NumberFormatLocal = "@"
- With .[b4].Resize(m, 24)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|