把分散的excel表,合并汇总到一张excel
步骤:
1、新建汇总excel
2、用excel打开工作表汇总
3、鼠标放在汇总sheet页,右键,单击查看代码
4、将以下代码复制到弹出窗口(如果excel文件是.xls,则只需要修改代码中的文件后缀即可)
Sub 工作薄间工作表合并() Dim FileOpen Dim X As Integer Application.ScreenUpdating = False FileOpen = Application.GetOpenFilename(FileFilter:="Microsoft Excel文件(*.xlsx),*.xlsx", MultiSelect:=True, Title:="合并工作薄") X = 1 While X <= UBound(FileOpen) Workbooks.Open Filename:=FileOpen(X) Sheets().Move After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count) X = X + 1 Wend ExitHandler: Application.ScreenUpdating = True Exit Sub errhadler: MsgBox Err.Description End Sub
5、