EXCEL合并工作表宏代码

  • 格式:doc
  • 大小:193.50 KB
  • 文档页数:3

EXCEL合并工作表宏代码(总1页)

--本页仅作为文档封面,使用时请直接删除即可--

--内页可以根据需求调整合适字体及大小-- Sub CombineWorkbooks()

Dim FilesToOpen

Dim x As Integer

On Error GoTo ErrHandler

= False

FilesToOpen = (FileFilter: = "MicroSoft Excel文件(*.xls),*.xls",MultiSelect: =

True,Title: = "要合并的文件")

If TypeName(FilesToOpen) = "Boolean" then

MsgBox "没有选中文件"

Goto ExitHandler

end if

x = 1

While x <= UBound(filestoopen)

fileName: = filestoopen(x)

Sheets().Move After: = x = x + 1

Wend

ExitHandler:

= True

Exit Sub

ErrHandler:

MsgBox

Resume ExitHandler End Sub