Code to save more than one sheet.

aspinray

New Member
Joined
Jan 14, 2016
Messages
16
Hi,

I posted earlier, but i have managed to get somewhere. I am using the below code to save a master spreadsheet (holiday planner) in another location however, it is only saving the one sheet i have specified but i want it to save all of the sheets. i don't know how to amend the code to save them all.

I can't save the whole workbook as a copy of as I have created the templates for where the "copy" saves as I don't want staff to see certain rows so have hidden these.

This is the code -

Sub beforesave()
Dim planWbk As Workbook
Dim planner As Workbook
Application.ScreenUpdating = False
Application.EnableEvents = True
Set planWbk = ActiveWorkbook


Workbooks.Open "\\Customer\shared\Exeter\Revenue Management\B2C Annual Leave\Martin Jose Planner.xls", , , , , "testing123"
Set planner = ActiveWorkbook


planner.Sheets("Inbound South - Plymouth").Activate
planner.Sheets("Inbound South - Plymouth").Unprotect


planWbk.Activate
Sheets("Inbound South - Plymouth").Activate
ActiveSheet.Unprotect
Cells.Select
Application.CutCopyMode = False
Selection.Copy
planner.Activate
Sheets("Inbound South - Plymouth").Select
Range("a1").PasteSpecial xlPasteValues
ActiveSheet.Protect
planner.Close True
planWbk.Activate
Sheets("Inbound South - Plymouth").Activate
Application.ScreenUpdating = True


Thanks in advance.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,216,523
Messages
6,131,151
Members
449,626
Latest member
Stormythebandit

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