|
参与一下。。。
- Sub ykcbf() '//2024.7.20 多工作簿合并
- Set fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("汇总")
- sh.UsedRange.Clear
- p = ThisWorkbook.Path & "\dj\280"
- For Each f In fso.GetFolder(p).Files
- If LCase$(f.Name) Like "*.xls*" Then
- m = m + 1
- 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 False
- If m = 1 Then
- sh.Cells(1, 1).Resize(r, c) = arr
- Else
- col = sh.Cells(1, 255).End(1).Column + 2
- sh.Cells(1, col).Resize(r, c) = arr
- End If
- End If
- Next f
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|