第2个回答 2019-09-20
使用这段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