printing selected sheets

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

Guest

I have been fiddling around for a while now trying to get my workbook to only
print worksheets that have data on them. Im quite new to visual basic and not
that great at it.

Is it possible to run a macro that can look to see if certain cells are
empty in a worksheet, and if so, not print that worksheet and go onto the
next one? So that it only prints worksheets that have had data entered onto
them.

If so, could you give me ideas on how to do it?
 
Hi Andy

This test cell A1 on each sheet
Change PrintPreview to printout if you like it


Sub Print_Visible_Worksheets()
'xlSheetVisible = -1
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Visible = -1 Then
If sh.Range("A1").Value <> "" Then
sh.PrintPreview
End If
End If
Next
End Sub
 
thats great cheers, thanks very much

Ron de Bruin said:
Hi Andy

This test cell A1 on each sheet
Change PrintPreview to printout if you like it


Sub Print_Visible_Worksheets()
'xlSheetVisible = -1
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Visible = -1 Then
If sh.Range("A1").Value <> "" Then
sh.PrintPreview
End If
End If
Next
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