Printing certain criteria

J

jns1999

I am interested in learning how to use criteria to print only certain
sheets as well. Here is my scenario:

I have approximately 500 sheets and each sheet contains a total. I
only want to print the sheets that have a total of $20 or greater. Is
this possible? If so, please inform me step by step because I do not
have much experience with macros.


Thanks,

Justin
 
R

Ron de Bruin

Try this Justin

It test cell A1 for the value > 20
Try it first on a test workbook with 10 sheets or so


Sub Print_Visible_Worksheets()
'xlSheetVisible = -1
Dim sh As Worksheet
Dim arr() As String
Dim N As Integer
N = 0
For Each sh In ThisWorkbook.Worksheets
If sh.Visible = -1 And sh.Range("A1") > 20 Then
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = sh.Name
End If
Next
With ThisWorkbook
.Worksheets(arr).PrintOut
.Worksheets(1).Select
End With
End Sub
 
Top