Hiding Worksheets


Posted by Bill on June 28, 2001 1:37 PM

Greetings

Can anyone help me with some code to hide all the worksheets in a workbook. I've tried this:

Private Sub Workbook_Open()
For Each sh In Sheets
sh.Visible = False
Next sh
End Sub

But of course it errors at the last sheet, I guess because there's nothing left for the For Next loop to count.

Grateful for any advice.

Bill C

Posted by Ron on June 28, 2001 1:50 PM

Bill,
Excel errors because one sheet must always be visible in a workbook.

Posted by faster on June 28, 2001 1:51 PM

You can't hide all the sheets. You need to have one
visible.



Posted by Ben O. on June 28, 2001 1:57 PM

Why not just hide the entire workbook window?

Windows("Book1").Visible = False

-Ben