View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bill Pfister Bill Pfister is offline
external usenet poster
 
Posts: 132
Default "pre-specify" print options

This code looks at all the worksheets to see if the value in A1 is true and
prints those sheets.

Regards,
Bill


Public Sub PrintSelectSheets_Variable()
Dim wkb As Workbook
Dim strSheets() As String
Dim lngFound As Long
Dim i As Long

Set wkb = ThisWorkbook
lngFound = -1

' Put all the sheets to print into the strSheets array
ReDim strSheets(0 To wkb.Sheets.Count - 1) As String

For i = 0 To wkb.Sheets.Count - 1
If (wkb.Sheets(i + 1).Range("A1").Value = True) Then
lngFound = lngFound + 1
strSheets(lngFound) = wkb.Sheets(i + 1).Name
End If
Next i

ReDim Preserve strSheets(0 To lngFound) As String

wkb.Sheets(strSheets).Printout

End Sub



"Eric" wrote:

Is there a way to setup the print button to check a cell for a non-blank
status in each sheet of a workbook and have that sheet print based on the
status of the cell? Thanks!