【VBA】合并多个excel文件
From http://www.zhihu.com/question/20366713
VBA代码如下:
1 Sub 工作薄间工作表合并() 2 3 Dim FileOpen 4 Dim X As Integer 5 Application.ScreenUpdating = False 6 FileOpen = Application.GetOpenFilename(FileFilter:="Microsoft Excel文件(*.xls),*.xls", MultiSelect:=True, Title:="合并工作薄") 7 X = 1 8 While X <= UBound(FileOpen) 9 Workbooks.Open Filename:=FileOpen(X) 10 Sheets().Move After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count) 11 X = X + 1 12 Wend 13 ExitHandler: 14 Application.ScreenUpdating = True 15 Exit Sub 16 17 18 errhadler: 19 MsgBox Err.Description 20 End Sub