Question : Prevent page printing if blank

Hello Experts,

I have a macro which filters a selction and then prints out the filter.  Sometimes the filter returns nothing and I would like a message to display saying 'Nothing to Report' and cancel the print job.

The macro to filter and print is:

    Selection.AutoFilter Field:=1, Criteria1:="Review"
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Selection.AutoFilter Field:=1

Thanks in advance for your help

Answer : Prevent page printing if blank

Full code including the message:

Selection.AutoFilter Field:=1, Criteria1:="Review"
If ActiveSheet.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1 <> 0 Then
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else
    MsgBox "Nothing to report, print job cancelled!"
End If
Selection.AutoFilter Field:=1
Random Solutions  
 
programming4us programming4us