我有一个包含10张的excel .xls
文件。我想将所有这些工作表拆分为单独的.xls
文件。 excel是否可以选择将工作表导出到单独的.xls
文件中?
答案 0 :(得分:0)
试试此代码
Sub Splitbook()
Dim xPath As String
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In ThisWorkbook.Sheets
xWs.Copy
Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & xWs.Name & ".xls", fileformat:=56
Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
这些是Excel 2007-2013中的主要文件格式,注意:在Excel for Mac中,值为+1
51 = xlOpenXMLWorkbook (without macro's in 2007-2013, xlsx)
52 = xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007-2013, xlsm)
50 = xlExcel12 (Excel Binary Workbook in 2007-2013 with or without macro's, xlsb)
56 = xlExcel8 (97-2003 format in Excel 2007-2013, xls)
6 = ".csv"
-4158 = ".txt"
36 = ".prn"
所有文件格式代码here