View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default Print If statement...

Tom,

You can loop through all the worksheets or loop through a list of worksheets

Dim wksh as Worksheet

For each wksh in thisworkbook.worksheets
wksh.PrintPreview
next

or

with worksheets listed on Sheet5 Range(A1:A5)

Dim wksh as String, x as Integer

For x = 1 to 5
wksh = Sheets("Sheet5").Cells(x,1).Text
Worksheets(wksh).PrintPreview
Next

or if you know how to build an array - than you can make your
idea work Worksheets(wksh1, wksh2, wksh3)
(unfortunately arrays are not my thing - they confuse me)

Another way to create a loop is either have a list on a worksheet and
an adjacent cell where you place a recognizable character as a check mark.
(x, 1, y, or .....) Than have the loop look for the character.

Or build a form to do this...

--
steveB

Remove "AYN" from email to respond
"Tom" wrote in message
...
thank you for your help, but how does it know which worksheet to print
with
the command line:

Worksheets(wksh).PrintPreview

Do I put all the worksheet names within this like the following:

Worksheets(wksh1, wksh2, wksh3).PrintPreview

Thank you for your help,
Thomas Vanderhoof
"STEVE BELL" wrote:

Something like the below (untested)

change MasterSheet to name of master sheet
change Range("A1:A25") to the appropriate range containing Active
cel.Offset(0,1) means the cell to the immediate right of the cell.
change
the 1 to the correct number.
Once you get it working - replace PrintPreview with PrintOut

====================================
Dim wksh As String, cel As Range

For Each cel In Sheets("MasterSheet").Range("A1:A25")
If LCase(cel) = "active" Then
wksh = cel.Offset(0, 1)
Worksheets(wksh).PrintPreview
End If
Next
=========================
--
steveB

Remove "AYN" from email to respond
"Thomas" wrote in message
...
Does anyone know if there is a way to print certain worksheets in a
workbook
based on values in a cell? I'm wanting to print all customers that are
currently active on the status worksheet. Each Customer has there own
worksheet. I would like to print their worksheet based on if they are
marked
"active" on the status worksheet. Any ideas, please feel free to tell
me.
--
Thank you,
Thomas Vanderhoof
Noble Phone Services, Inc.