Hello all. I am working on a project that is two part. I am working with Excel 2007. I have a workbook that has 50 or so worksheets that I need to split and save as individual files. I found the following code online. It works fine, however, I need the "new" workbooks to be saved as Excel 97-2003 files. What do I need to add to this to make that happen?
Part Two is this: I have another file that I'm needing to split as well. However, the information in this workbook is organized in a Pivot Table. I have utilized the 'Show Report Filter Pages' to have the information on separate worksheets so that I can split the file. Will the above code (with the modification to save in 97-2003 format) work with the Pivot Table?Sub splitsheettoworkbook() Dim wbDest As Workbook Dim wbSource As Workbook Dim sht As Worksheet 'Could be chart, worksheet, Excel 4.0 macro,etc. Dim strSavePath As String On Error GoTo ErrorHandler Application.ScreenUpdating = False 'Don't show any screen movement strSavePath = "C:\Excel Worksheets\" 'Change this to suit your needs Set wbSource = ActiveWorkbook For Each sht In wbSource.Sheets sht.Copy Set wbDest = ActiveWorkbook wbDest.SaveAs strSavePath & sht.Name wbDest.Close 'Remove this if you don't want each book closed after saving. Next Application.ScreenUpdating = True Exit Sub ErrorHandler: 'Just in case something hideous happens MsgBox "An error has occurred. Error number=" & Err.Number & ". Error description=" & Err.Description & "." End Sub
Last edited by ksteffin; 02-25-2011 at 06:07 PM.
Try
change this towbDest.SaveAs strSavePath & sht.Name
wbDest.SaveAs strSavePath & sht.Name & ".xls"
That works great! One more question. The original workbook contains reports that I need to split and send out each month. If i wanted to add "March Reports" to the sheet name only when saving it, how would I do that? Could I add "March Reports" like this?
wbDest.SaveAs strSavePath & sht.Name "March Reports" & ".xls"
Thanks for your help, aravindhan_31!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks