Parse excel sheets into new workbooks

andream02

Board Regular
Joined
Jul 26, 2007
Messages
70
Hello! I have a file that contains the same worksheets each month - approx 15. Each month I end up copying the sheets into new workbooks and saving them so I can email them out individually.

I'm hoping someone could help me with the VBA code required to extract the sheets into new workbooks and save them, as the tab name, into the desired location on my C: Drive. Its important that the code translates the data from the original sheet into the new workbook. I've tried code that creates the tab in a new workbook, but the cells are blank. :(

Any and all help is much appreciated.

Thank you!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try

Code:
Sub savesheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
    ws.Copy
    With ActiveWorkbook
        .SaveAs Filename:=ws.Name & Format(Date, "ddmmyyyy") & ".xls"
        .Close
    End With
Next ws
End Sub
 
Upvote 0
Something like this perhaps.
Code:
Sub SplitWB()
Dim wbNew As Workbook 
Dim wbThis As Workbook 
Dim ws As Worksheet
Dim strFileName As String

    Set wbThis =ThisWorkbook

    For Each ws In wbThis.Worksheets

         strFileName=ws.Name

         ws.Copy 

         Set wbNew = ActiveWorkbook

          wbNew.SaveAs "C:\"& strFileName

          wbNew.Close False 

     Next ws

End Sub
Change the save path/folder needed.
 
Upvote 0
Hopefully a simple and quick question regarding the file name and date - how do I insert a space between the tab name and the date? right now I see the following:

Finance 4114923062011

I would like to see:

Finance 41149 - 23062011

Wasn't sure if I'm able to concatenate the code by adding &" -" after ws. Name.
.SaveAs Filename:=ws.Name & Format(Date, "ddmmyyyy") & ".xls"

Thanks!
 
Upvote 0
Try

Code:
        .SaveAs Filename:=ws.Name & " - " & Format(Date, "ddmmyyyy") & ".xls"
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top