Tom’s Tutorials For Excel: Printing Some Sheets, Not Printing Others
In some cases you want an easy way to print only certain sheets from your workbook.
There are two approaches — identifying which sheets to include, or which sheets to exclude.
Below are two macros, one showing an example for inclusion and the other for exclusion.
Sub PrintInclude() Dim i%, mySheets As Variant mySheets = (Array("Sheet1", "Sheet3", "Sheet8", "Sheet14")) For i = LBound(mySheets) To UBound(mySheets) Worksheets(mySheets(i)).PrintOut Next i End Sub
Sub PrintExclude() Dim ws As Worksheet For Each ws In Worksheets If ws.Name <> "Sheet1" And ws.Name <> "Sheet2" Then ws.PrintOut Next ws End Sub
I have a worksheet that has 50 each, formatted pages. All pages are on one excel sheet. Each day I may want to print only certain pages (I.e. Page 1,2,4,6,45) depending on whether or not data is entered in a page or not. Is there a macro that can do this automatically after data is entered each day?
Can you not use the From and To arguments for whichever page(s) you want to print?
Using your example:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.ScreenUpdating = False
.PrintOut From:=1, To:=2
.PrintOut From:=4, To:=4
.PrintOut From:=6, To:=6
.PrintOut From:=45, To:=45
Application.ScreenUpdating = True