ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Save sheets in a folder (https://www.excelbanter.com/excel-worksheet-functions/92841-save-sheets-folder.html)

SBárbara

Save sheets in a folder
 
How can i Save in separate files the sheets of my worksheet, without being
one by one...

Regards,
S Bárbara

Ron de Bruin

Save sheets in a folder
 
Hi SBárbara

Try
http://www.rondebruin.nl/copy6.htm


--
Regards Ron De Bruin
http://www.rondebruin.nl



"SBárbara" wrote in message ...
How can i Save in separate files the sheets of my worksheet, without being
one by one...

Regards,
S Bárbara




[email protected]

Save sheets in a folder
 

SBárbara wrote:
How can i Save in separate files the sheets of my worksheet, without being
one by one...

Regards,
S Bárbara


Here's one way to do it.
1. Open the workbook you want to copy from.
2. Press Alt-F11 to show the editor.
3. Click Insert on the menu, then Module.
4. Copy and insert the code shown below.
5. Press Alt-F11 to return to the spreadsheet view.
6. Save the file
7. See notes below! When ready, run the sub (Tools|Macros|select
SaveSheets from the list)

Sub SaveSheets()
Dim j As Integer
Application.DisplayAlerts = False
With ThisWorkbook
For j = 1 To .Worksheets.Count
.Worksheets(j).Activate
ActiveSheet.Copy
ActiveWorkbook.SaveAs "C:\myFolder\" & ThisWorkbook.Name _
& "_" & ActiveSheet.Name & ".xls"
ActiveWorkbook.Close
Next j
End With
Application.DisplayAlerts = True
End Sub

Notes:
1. This presumes you have created a folder called myFolder on your C:
drive to hold the new workbooks. If you want to use a different path,
change the name of the path in the code.
2. This code saves the resulting workbooks with the name of the main
workbook plus an underscore plus the name of the sheet.
3. The next time you run the routine, it will not ask you if you want
to replace the existing workbooks. If you want it to ask you whether
to replace the existing workbooks, remove the lines that include the
words DisplayAlerts.

James



All times are GMT +1. The time now is 02:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com