ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   "pre-specify" print options (https://www.excelbanter.com/excel-programming/373666-pre-specify-print-options.html)

Eric

"pre-specify" print options
 
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!

Bill Pfister

"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!



All times are GMT +1. The time now is 01:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com