.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)