Conditional Printing

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hi,

I would like to know if anybody has any VB script that will allow me
to conditionally print worksheets. Currently I have a workbook that
has 30 worksheets, I want the script to look at one cell in each
worksheet and if that cell is > 1 then it prints the worksheet.
Thanks.

James
 
James

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
If Sheets(n).Range("A1").Value = 1 Then
Sheets(n).PrintPreview 'PrintOut
End If
Next n
Application.ScreenUpdating = True
End Sub

Place code into Thisworkbook Module or change name to

Sub Print_Sheets() and place into a general module and run when you want.


Gord Dibben MS Excel MVP
 
Back
Top