Macro to select and print sheets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to know the code for use in a macro that will
1. look at cell G1 in a sheet and if there is a number in that cell print
the sheet
2. move to the next sheet and look at cell G1 and if there is a number in
that cell print the sheet
3. continue to move to each sheet in the file test cell G1 to see if there
is a number and print the sheet if there is.

Thanks for any help.
 
something like

for each ws in worksheets
if ws.range("g1")>0 then activesheet.printout
next ws
 
Option Explicit
Sub testme()

Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
With wks.Range("g1")
If IsEmpty(.Value) Then
'skip it
Else
If IsNumeric(.Value) Then
.Parent.PrintOut Preview:=True
End If
End If
End With
Next wks

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top