|

楼主 |
发表于 2021-9-15 09:01
|
显示全部楼层
一些excel的自学笔记:
合并工作簿
Sub 合并工作簿()
Dim FileOpen
Dim X As Integer
Application.ScreenUpdating = False
FileOpen = Application.GetOpenFilename(FileFilter:="Microsoft Excel文件(*.xlsx),*.xlsx", MultiSelect:=True, Title:="合并工作薄")
MsgBox (FileOpen(2))
X = 1
While X <= UBound(FileOpen)
Workbooks.Open Filename:=FileOpen(X), Password:=""
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Password:="" '删除文件保护密码
Sheets().Move After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
X = X + 1
Wend
ExitHandler:
Application.ScreenUpdating = True
Exit Sub
errhadler:
MsgBox Err.Description
End Sub
|
|