Print all visible sheets exept one

grady121

Active Member
Joined
May 27, 2005
Messages
381
Office Version
  1. 2016
Platform
  1. Windows
I have a workbook containing several sheets, some of which are hidden and some are not.
All I want to do is print out all of those that are visible, exept for the one named sheet (Input1)
I've managed to find a code from the Microsoft site but this only covers all the visible sheets.
Is there anyone who knows how to modify the code to exclude this one named sheet, or does it require a new code?

Code:
Sub Print_Visible_Sheets()
      Dim sht

      ' Turn off the screen redraw.
      Application.ScreenUpdating = False
      ' Loop through for all sheets in the workbook.
      For Each sht In Sheets
         ' If the current sheet is visible, then group it with the rest.
         If sht.Visible Then sht.Select Replace:=False
      Next

      ' Print all of the selected sheets.
      ActiveWindow.SelectedSheets.PrintOut copies:=1
      ' Ungroup the sheets.
      ActiveSheet.Select
      ' Turn back on the screen redraw.
      Application.ScreenUpdating = True
   End Sub

Thanks in advance.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Macropheliac

Board Regular
Joined
Aug 26, 2005
Messages
165
Try this:

Code:
Sub print_sheets()
Dim sheet As Worksheet

For Each sheet In ActiveWorkbook.Sheets
        If sheet.Visible = True And sheet.Name <> "input1" Then
                sheet.PrintOut copies:=1
        End If
Next sheet
End Sub
 

grady121

Active Member
Joined
May 27, 2005
Messages
381
Office Version
  1. 2016
Platform
  1. Windows
Brilliant Macropheliac - it worked just fine.
It was so good you called it twice.

Many thanks.
 

Forum statistics

Threads
1,136,878
Messages
5,678,324
Members
419,756
Latest member
vincent86kapelski

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top