![]() |
Conditional Printing
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 |
Conditional Printing
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 On Tue, 24 Jul 2007 12:36:32 -0700, James wrote: 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 |
All times are GMT +1. The time now is 06:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com