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:

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
43,419
Office Version
365
Platform
Windows
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
 

RichJH

New Member
Joined
Sep 3, 2019
Messages
9
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?
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
43,419
Office Version
365
Platform
Windows
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
 

Forum statistics

Threads
1,089,233
Messages
5,407,043
Members
403,119
Latest member
Lara465

This Week's Hot Topics

Top