Save sheets in a folder

G

Guest

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

Regards,
S Bárbara
 
J

jkend69315

SBárbara said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top