【发布时间】:2019-04-04 16:50:19
【问题描述】:
我有许多不同工作表和相同格式的 excel。是否有任何插件可用于将所有工作表组合成目标文件中的“合并”工作表?
但是下面的代码不能合并成一张
Sub GopFileExcel()
Dim FilesToOpen
Dim x As Integer
On Error GoTo ErrHandler
Application.ScreenUpdating = False
FilesToOpen = Application.GetOpenFilename _
(FileFilter:="hMicrosoft Excel Files (*.xlsx), *.xlsx",
MultiSelect:=True, Title:="Files to Merg")
If TypeName(FilesToOpen) = “Boolean” Then
MsgBox "No Files were selected"
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
【问题讨论】: