多个Excel 合并成1个文档

在同文件夹新建

打开开发工具粘贴代码

Sub 多表多文件合并为多表一文件()

Dim FileArray

Dim X As Integer

Application.ScreenUpdating = False

FileArray = Application.GetOpenFilename(FileFilter:="Microsoft Excel文件(*.xlsx),*.xlsx", MultiSelect:=True, Title:="合并工作薄")

X = 1

While X <= UBound(FileArray)

Workbooks.Open Filename:=FileArray(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

你可能感兴趣的:(多个Excel 合并成1个文档)