将多个Excel文件合并为一个Excel文件

作者:国际小甜 | 创建时间: 2023-04-30
将多个Excel文件合并为一个Excel文件...
将多个Excel文件合并为一个Excel文件

操作方法

如何将100个excel文件合并成1个excel100个工作表,每个工作表名字对应原excel文件将多个Excel文件合并为一个Excel文件 步骤:宏--创建--输入下面内容: Sub CombineWorkbooks() Dim FilesToOpen Dim x As Integer On Error GoTo ErrHandler Application.ScreenUpdating = False FilesToOpen = Application.GetOpenFilename _ (FileFilter:="MicroSoft Excel文件(*.xls),*.xls", _ MultiSelect:=True, Title:="要合并的文件") If TypeName(FilesToOpen) = "Boolean" Then MsgBox "没有选中文件" GoTo ExitHandler End If x = 1 While x <= UBound(FilesToOpen) Workbooks.Open Filename:=FilesToOpen(x) Sheets().Move after:=ThisWorkbook.Sheets _ (ThisWorkbook.Sheets.Count) x = x + 1 Wend ExitHandler: Application.ScreenUpdating = True Exit Sub ErrHandler: MsgBox Err.Description Resume ExitHandler End Sub

点击展开全文

更多推荐