Active Worksheets Save as

John

New Member
Joined
Mar 12, 2002
Messages
24
Can any one help me with a macro to save only the active worksheets in a workbook using the save as function?
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

phantom1975

MrExcel MVP
Joined
Jun 3, 2002
Messages
3,962
Will this do?

<font face=Courier New><SPAN style="color:darkblue">Sub</SPAN> Copy_to_New_Workbook()

    ActiveSheet.Copy
    <SPAN style="color:darkblue">With</SPAN> ActiveWorkbook
        .SaveAs "C:\Documents and Settings\All Users\Desktop\Testing.xls"
        .<SPAN style="color:darkblue">Close</SPAN>
    <SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>
 

John

New Member
Joined
Mar 12, 2002
Messages
24
Thanks
I should have explained myself better.
I could have 1 or more worksheets I need to save. (there are other hidden worksheets I don't want included in the save as. I want to be able to select and save this group and ideally have the save as prompt pop up so I can give each save a new name. Is this possible?
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
A little tweak to what Billy provided you might do it:
Code:
Sub Copy_to_New_Workbook()
    Dim ws As Worksheet
        For Each ws In ActiveWorkbook.Worksheets
            If ws.Visible = True Then
                ws.Activate
                    ActiveSheet.Copy
                        With ActiveWorkbook
                            .SaveAs "C:\Documents and Settings\All Users\Desktop\" & _
                                InputBox("Please enter the Save As Name...", "Worksheet Save As") & ".xls"
                            .Close
                        End With
                    End If
                Next ws
End Sub
Hope that helps,

Smitty
 

z4x3r

New Member
Joined
Sep 8, 2009
Messages
35
Hi guys,

I would like to add another twist to this problem.

Imagine I have a workbook with 10 sheets.

I would like to copy just 3 of those sheets (indicating which one I would like to be copied referring to the sheet name) into a new workbook and save that new workbook with a name given by the user and in a path set by me.

How could I do that?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,721
Messages
5,597,752
Members
414,171
Latest member
12Rev79

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
Top