Split 5-sheet workbook so only 2 sheets are saved into 1 new workbook

Reiper79

New Member
Joined
Jun 15, 2021
Messages
19
Office Version
  1. 365
Platform
  1. Windows
My workbook has 5 sheets, but I want only two sheets saved to one new workbook.

Can someone please help me create a macro within my workbook so it runs when I click a button I use for another macro?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
You just need to copy the sheets

VBA Code:
Sub CopyOver()
    Sheets(Array("Sheet3", "Sheet4")).Copy
    ActiveWorkbook.SaveAs Filename:="C:\Users\andrew.marshall\Desktop\test.xlsx"
End Sub
 
Upvote 0
Excellent. Thanks.

What if I want the new workbook to automatically save to the same location as the original but named using: value of a cell_Assess - Driving_value of a cell ?
 
Upvote 0
I'm not sure what you mean with the cells sorry.

For the Path though:

VBA Code:
Sub CopyOver()
    myPath = Application.ActiveWorkbook.Path
    Sheets(Array("Sheet3", "Sheet4")).Copy
    ActiveWorkbook.SaveAs Filename:=myPath & "test.xlsx"
End Sub
 
Upvote 0
Solution
Thanks very much.

The first cell I'm referring to is the Driver's Name field. The second is the Assessment Date field.

Is that possible to do?
 
Upvote 0
Yes, something like this i'd suppose

VBA Code:
 myPath & "\" & Range("A1") & Range("A2") & ".xlsx"
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

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