Make it not print rows using this routine

J

John

I have a workbook with 3 worksheets. The worksheet where
I want rows to hide and not print if there is no data in
Column Q on that particular row (in other words, print
only rows that have data in Column Q) is called Master
Schedule. Rows 9 through 200 is where data is stored,
except that some of those rows do not have data in column
Q, so I would like those particular rows not to print.
Using this routine and placing it in 'ThisWorkbook
(Code)', how can I change this code to make it work as
right now it does not work.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Master Schedule" Then
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet
.Rows("9:200").EntireRow.Hidden = True
.PrintOut
.Rows("9:200").EntireRow.Hidden = False
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top