Please Help Me Annotate Subroutine
I'll assist. I'm sure Bernie will correct me if I'm wrong.
Sub PrintJob()
Dim Sel As Boolean 'Options for Boolean are TRUE and FALSE
Dim myS As Worksheet 'Should be self explanatory
Sel = True
'Loops through all Worksheets in the active workbook
' If there are "Chart Sheets", they won't be included.
For Each myS In Worksheets
'Tests to see if WOrksheet is Hidden.
'Visible property can be Visible, Hidden and Very Hidden, IIRC.
If myS.Visible Then
'Checks value in Cell F52 of the current worksheet
If myS.Range("F52").Value 0 Then
'Selects the "current" worksheet and I presume if SEL is false, it adds it to
' a group of worksheets that are selected.
myS.Select Sel
Sel = False
End If
End If
Next myS
'Prints out the selected sheets in the active workbook.
ActiveWindow.SelectedSheets.PrintOut
End Sub
HTH,
Barb Reinhardt
"RST Engineering (jw)" wrote:
..
..
Bernie ...
I saw it after I posted my question. It seems somebody hijacked my original
post from a week ago and passed it off as their own under a different
Subject. I will certainly try your code. However, it seems like your code
prints sheets out one by one, doesn't it? Or does it batch print them?
The problem with printing one by one is that when you go to "print" to a pdf
file each sheet has to be given a different file name, then you have to
assemble all the pdf files into one file, making sure that the sheets are
all in order (which they rarely are).
Can you step me through your code, treating me as you would any other
freshman history major?
{;-)
Jim
--
"It is the mark of an educated mind to be able to entertain a thought
without accepting it."
--Aristotle
"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Jim,
Did you try this code that I posted?
Sub PrintJob()
Dim Sel As Boolean
Dim myS As Worksheet
Sel = True
For Each myS In Worksheets
If myS.Visible Then
If myS.Range("F52").Value 0 Then
myS.Select Sel
Sel = False
End If
End If
Next myS
ActiveWindow.SelectedSheets.PrintOut
End Sub
HTH,
Bernie
MS Excel MVP
|