如何将多个excel文件作为不同sheet都导入一个excel文件中

如题所述

使用这段VB吧,生成的工作表名是按原表名+1.2.3.4.5这样来的.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
温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜