Select Visible sheets

  • Thread starter Thread starter Darin Kramer
  • Start date Start date
D

Darin Kramer

HI guys,

Whats the VBA to select all visible sheets and print them?

Visiblesheets.select?

Thanks

D
 
Sub PrintVisibleSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Visible Then
ws.PrintOut Copies:=1, Collate:=True
End If
Next
End Sub
 
If you want them as one print job:

Sub SelectVisible()
Dim bReplace as Boolean, sh as worksheet
Dim shActive as worksheet
set shActive = Activesheet
bReplace = True
For Each sh In ThisWorkbook.Worksheets
If sh.Visible Then
sh.Select bReplace
bReplace = False
End If
Next
ActiveWindow.SelectedSheets.PrintOut
shActive.select
End Sub
 
Thanks Perfect! - Forgot to ask...if I want to exclude a specifically
named sheet (say called Contents) is that also possible?
 
If your happy with multiple print jobs rather than what you asked then:

Sub PrintVisibleSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Visible Then
if ws.Name <> "Contents" then
ws.PrintOut Copies:=1, Collate:=True
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