ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Printing certain criteria (https://www.excelbanter.com/excel-discussion-misc-queries/67069-printing-certain-criteria.html)

[email protected]

Printing certain criteria
 
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


Ron de Bruin

Printing certain criteria
 
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


--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message ups.com...
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





All times are GMT +1. The time now is 07:08 PM.

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