Macro - Print sheets between two marker sheets

RichJH

New Member
Joined
Sep 3, 2019
Messages
9
Hello,

I have multiple files with varying working and backup sheets but I would like to create a macro that will print the main group of tabs which will always vary in actual names.

My initial thought was to create marker workbooks named 'start' and 'end' for example that would mark the required tabs for ease of selection.

Can I create a macro (to link to button) that will select all the tabs between these to be ready for printing?

Cheers
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
My initial thought was to create marker workbooks named 'start' and 'end' for example that would mark the required tabs for ease of selection.

Can I create a macro (to link to button) that will select all the tabs between these to be ready for printing?
See if this does what you want.
Code:
Sub Select_Sheets()
  Dim i As Long
  
  Sheets(Sheets("start").Index + 1).Select
  For i = Sheets("start").Index + 2 To Sheets("end").Index - 1
    Sheets(i).Select Replace:=False
  Next i
End Sub
 
Upvote 0
See if this does what you want.
Code:
Sub Select_Sheets()
  Dim i As Long
  
  Sheets(Sheets("start").Index + 1).Select
  For i = Sheets("start").Index + 2 To Sheets("end").Index - 1
    Sheets(i).Select Replace:=False
  Next i
End Sub

Perfect thank you, what would the best way to unselect these sheets after printing, would like to prevent multiple sheet cells changes?
 
Upvote 0
Perfect thank you, what would the best way to unselect these sheets after printing, would like to prevent multiple sheet cells changes?
That is a very good idea. :)

Perhaps something like this
Rich (BB code):
Sub Select_Sheets()
  Dim i As Long
  
  Sheets(Sheets("start").Index + 1).Select
  For i = Sheets("start").Index + 2 To Sheets("end").Index - 1
    Sheets(i).Select Replace:=False
  Next i
  
  ActiveWindow.SelectedSheets.PrintOut
  
  Sheets(Sheets("start").Index + 1).Select Replace:=True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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