Create new workbooks from selected sheets in master workbook

alyssa75

Board Regular
Joined
May 14, 2007
Messages
240
Hi all - looking for some help with the following:


For each SELECTED worksheet in the activeworkbook, I want to create a new workbook, with values only (no formulas) and save it to the same path as the master workbook. Name of the new workbook would be the sheet name.


Thanks!
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Code:
Sub Save_Selected_Sheets()
    
    Dim wb As Workbook, ws As Worksheet, Ext As String, ff As Integer
    
    Application.ScreenUpdating = False
    
    Select Case ThisWorkbook.FileFormat
        Case 50, 51, 52
            ff = 51
            Ext = ".xlsx"
        Case Else
            ff = ThisWorkbook.FileFormat
            Ext = ".xls"
    End Select
    
    For Each ws In ActiveWindow.SelectedSheets
        ws.Copy
        Set wb = ActiveWorkbook
        wb.Sheets(1).UsedRange.Value = wb.Sheets(1).UsedRange.Value
        On Error Resume Next
        wb.SaveAs Filename:=ThisWorkbook.Path & "\" & wb.Sheets(1).Name & Ext, _
                  FileFormat:=ff
        On Error GoTo 0
        wb.Close SaveChanges:=False
    Next ws
    
    Application.ScreenUpdating = True
    
    MsgBox "Selected sheets saved."

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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