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.
So like when someone goes to File -> Print or whatever, and hit OK, etc, everything prints out except for a particular designated tab (which I assume I have to "hide from printing" somehow).
I'm sending this workout out to a bunch of people so I'm trying to avoid forcing them to enable/run macros and all that stuff. Is there just a property of a sheet somewhere like "exclude from print"?
These answers will require the use of macros.
Hide the sheet before printing.
sheets("WorksheetToNotPrint").visible = xlSheetHidden 'or 0
or
sheets("WorksheetToNotPrint").visible = xlSheetVeryHidden 'or 2
'used if you don't want people to unhide the worksheet without knowing code
and
sheets("WorksheetToNotPrint").visible = xlSheetVisible 'or -1
when done
another option is to print the sheets you want printed (may be useful if you only want a few sheets printed:
Sub Print_Specific_Sheets()
Sheets(Array("Sheet1", "Sheet2", "Sheet4")).Select
ActiveWindow.SelectedSheets.PrintOut
Sheets("Sheet1").Select
End Sub
Actually the answer seems to be surprisingly simple.
If you hide the sheet, it will not be printed when you print the entire workbook.
You won't need a macro, just
hide
If needed you or other users can unhide it as well.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With