For Next & Hidden Sheets Issue

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
 
M

Melanie Breden

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)
 
B

Bob Phillips

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)
 
B

Bob Phillips

oops, change the <> to =

--

HTH

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