|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.6.21
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set fso = CreateObject("scripting.filesystemobject")
- Dim arr, brr(1 To 10000, 1 To 100)
- Set sh = ThisWorkbook.Sheets("Sheet1")
- p = ThisWorkbook.Path & ""
- For Each f In fso.GetFolder(p).Files
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- n = n + 1
- fn = fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- arr = .UsedRange
- wb.Close False
- End With
- For i = IIf(n = 1, 1, 2) To UBound(arr)
- If arr(i, 1) <> Empty Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- End If
- Next f
- With sh
- .UsedRange.ClearContents
- .[a1].Resize(1, UBound(arr, 2)).Interior.Color = 49407
- With .[a1].Resize(m, UBound(arr, 2))
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .EntireColumn.AutoFit
- End With
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|