Is there any way in Excel to make it so that a particular tab isn\'t included when you print the entire workbook? As in, Sheet1, Sheet2, and Sheet3 print, but not Sheet4.
If you use the BeforePrint
event then you can alter what the built in print function can do. The BeforePrint
macro is inside 'ThisWorkbook' under 'Workbook'.
For example you can hide sheet 4 so it doesn't print like this:
Private Sub aWorkbook_BeforePrint(Cancel As Boolean)
Sheets(4).Visible = xlSheetHidden
End Sub
The downside to this method is there is no AfterPrint
method to unhide the sheets. So you need to circumvent the print dialog. There are several ways to do this but here is one very simplistic method. (Note: This might not be a good solution if you have many other printing scenarios that you need to account for)
Here I am telling exactly what sheets to print (only sheet 1 and 4). You can use names instead of numbers and you can even create a loop and look for variables to determine what sheets you want to print.
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.EnableEvents = False
Sheets(Array("1", "4")).PrintOut , , 1
Application.EnableEvents = True
'//prevent the default print
Cancel = True
End Sub