VBA to Save selected sheets as new Workbook

initiator

New Member
Joined
May 13, 2010
Messages
16
hi all,

I have a main processing file with say 10 sheets. After processing I want to save selected sheets (1, 4 and 5) as a new excel file. The code I have found so far saves each sheet as a separate file, however, I want to combine the selected sheets in one file.

Any ideas?

thanks!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try like this

Code:
Sheets(Array("Sheet1", "Sheet4", "Sheet5")).Copy
 
Upvote 0
Thanks a lot Peter! . It works!

There's a small issue, however. One of the sheets has formulae, and copied sheet in the newly saved file is still referencing to those formula in the main sheet. Any way to copy values and formats only?

thanks
 
Upvote 0
Try

Code:
Dim ws As Worksheet
Sheets(Array("Sheet1", "Sheet4", "Sheet5")).Copy
For Each ws In ActiveWorkbook.Worksheets
    With ws.UsedRange
        .Value = .Value
    End With
Next ws
 
Upvote 0
I was searching for a solution and this basically does it. I dont have much experience in VBA so i got an additional question:

Can you also use a specific path to save the new Spreadsheet i an Folder?
And i also want to use an custom Name for the File.
What do i have to add to your code VoG?

Thank you in advance.
 
Upvote 0
I was searching for a solution and this basically does it. I dont have much experience in VBA so i got an additional question:

Can you also use a specific path to save the new Spreadsheet i an Folder?
And i also want to use an custom Name for the File.
What do i have to add to your code VoG?

Thank you in advance.
WS.Copy
'add path
ChDir "D:\Alex\汇报工作\K3"
ActiveWorkbook.SaveAs Filename:="D:\Alex\汇报工作\K3\" & ActiveSheet.Name & ".xlsx"
ActiveWorkbook.Close
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,830
Members
449,096
Latest member
Erald

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