For Next & Hidden Sheets Issue

  • Thread starter Thread starter Far
  • Start date Start date
F

Far

The following procedure creates an error if there is
hidden sheets in workbook. How can I have this procedure
ignore the hidden sheets? ... Thanks

Sub Set_Page_Preview_Normal()
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
wks.Select
ActiveWindow.View = xlNormalView
Next wks
End Sub
 
Hi Far,
The following procedure creates an error if there is
hidden sheets in workbook. How can I have this procedure
ignore the hidden sheets? ... Thanks

try this:
For Each wks In ActiveWorkbook.Worksheets
If wks.Visible = xlSheetVisible Then
wks.Select
ActiveWindow.View = xlNormalView
End If
Next wks

--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)
 
Sub Set_Page_Preview_Normal()
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
If wks.Visible <> xlSheetVisible Then
wks.Select
ActiveWindow.View = xlNormalView
End If
Next wks
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
oops, change the <> to =

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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