求VBA代码完成任务,多谢。想用VBA
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 "没有...全部
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 。收起