GoKats78
03-10-2014, 03:27 AM
have been using the following code to group worksheets (and subsequently ungroup) to print (and print preview). This was developed for Excel 2003 and worked well. It works well to PRINT in Excel 2010, but doesn't work at all for the print preview function. What changes do I need to make to group the print preview as well?
I substituted Sheet1, Sheet2... for the actual sheet names in the example
To Group:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Sheets(Array("Sheet1")).Select
Cancel = True
Sheets(Array("Sheet2", "Sheet3", "Sheet4", " Sheet5", " Sheet6")).Select
Cancel = False
Application.OnTime Now, "AfterPrint"
End Sub
To Ungroup:
Private Sub AfterPrint()
'code to run after the print event
Sheets("Sheet2").Select
Range("A4").Select
End Sub
I substituted Sheet1, Sheet2... for the actual sheet names in the example
To Group:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Sheets(Array("Sheet1")).Select
Cancel = True
Sheets(Array("Sheet2", "Sheet3", "Sheet4", " Sheet5", " Sheet6")).Select
Cancel = False
Application.OnTime Now, "AfterPrint"
End Sub
To Ungroup:
Private Sub AfterPrint()
'code to run after the print event
Sheets("Sheet2").Select
Range("A4").Select
End Sub