|
多文件合并- Sub ykcbf() '//2025.1.13
- Set fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- sh.UsedRange.Clear
- p = ThisWorkbook.Path & ""
- For Each f In fso.GetFolder(p).Files
- If LCase$(f.Name) Like "*.xls*" Then
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- Set wb = Workbooks.Open(f, 0)
- n = n + 1
- r = IIf(n = 1, 1, sh.Cells(Rows.Count, 1).End(3).Row + 1)
- wb.Sheets(1).UsedRange.Copy sh.Cells(r, 1)
- wb.Close False
- End If
- End If
- Next f
- sh.Activate
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|