PDA

View Full Version : [SOLVED:] Making multiple files.



rdelosh74
07-29-2014, 07:09 AM
Need help please.

I need a macro that will take every sheet and make a new workbook the same name as the sheet for every sheet starting on the 5th sheet to the end. And to copy the contents of the original sheet to the new workbook.

So for instance if the sheets in the original workbook were numbered. 1 2 3 4 5 6 7 8 9 10 11 12 13.

I would end up with the original workbook. And the following workbooks:
5, 6, 7, 8, 9, 10, 11, 12, 13.

And the data in workbook 5 would be the same data as in the original workbook on sheet 5.

If that makes sense.


Thank you very much.

ranman256
07-29-2014, 07:28 AM
Public Sub SaveAllSheetsSolo()
Dim wb As Workbook
Dim s As Integer
Set wb = ActiveWorkbook
For s = 5 To Sheets.Count
Sheets(s).Select
Sheets(s).Copy
'save as here
wb.Activate
Next
Set wb = Nothing
End Sub

rdelosh74
07-30-2014, 06:25 AM
Perfect! Except I believe I explained it wrong. I need each of the new files to be the same name as the tab it came from. And for it to automatically save and close (in the same folder as the source file) the files if possible. Other than that (which is my fault), perfect.

Thank you.

westconn1
07-30-2014, 02:41 PM
so put the path and filename in the saveAs code, where ranman put the comment

something like
[/code]activeworkbook.saveas wb.path & "\" & sheets(s).name & ".xls"[code]

rdelosh74
08-01-2014, 01:18 PM
Thank you for your help on this. Unfortunately. My company has decided to close its doors on this building and move all of its operations to its other building in another city.