I have a spreadsheet with multiple tabs. I would like to be able to select various tabs for printing page 1. For one specific tab I would like to filter a table, then print pages 1 & 3. I have written a macro, put it inside a workbook _BeforePrint event which runs the macro, but it prints the tab twice. Once from the print event and once by calling the macro.
Is there a way of overwriting the print event for this specific tab when it's printed? or is there a better solution to this problem?
Thanks in advance,
Tim
Sub print_pages1n3()
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$249"
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True, IgnorePrintAreas:=False
ActiveSheet.PageSetup.PrintArea = "$A$1:$K$249"
ActiveWindow.SelectedSheets.PrintOut From:=3, To:=3, Copies:=1, Collate _
:=True, IgnorePrintAreas:=False
Range("E30").Select
End Sub
Sub filterData()
Worksheets("13-33").Activate
ActiveSheet.ListObjects("Table8").Range.AutoFilter Field:=1, Criteria1:= _
"<>"
End Sub
Sub Unfilter()
Worksheets("13-33").Activate
ActiveSheet.ListObjects("Table8").Range.AutoFilter Field:=1
End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
Call filterData
Call print_pages1n3
Cancel = False
Call Unfilter
End Sub
Bookmarks