|
本帖最后由 wei_dan 于 2020-1-14 11:18 编辑
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)
drcount = Workbooks(FileOpen(X)).Worksheets.Count ‘ 报错
For i = 1 To drcount
With Workbooks(FileOpen(X))
.Sheets(i).Copy after:=ThisWorkbook.Sheets(Sheets.Count)
End With
Next
Workbooks(FileOpen(X)).Close False
X = X + 1
Wend
ExitHandler:
Application.ScreenUpdating = True
Exit Sub
errhadler:
MsgBox Err.Description
End Sub
错误
|
|