ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For Next & Hidden Sheets Issue (https://www.excelbanter.com/excel-programming/295943-next-hidden-sheets-issue.html)

Far

For Next & Hidden Sheets Issue
 
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

Melanie Breden

For Next & Hidden Sheets Issue
 
Hi Far,

Far schrieb:
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)


Bob Phillips[_6_]

For Next & Hidden Sheets Issue
 
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)

"Far" wrote in message
...
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




Bob Phillips[_6_]

For Next & Hidden Sheets Issue
 
oops, change the < to =

--

HTH

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

"Bob Phillips" wrote in message
...
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)

"Far" wrote in message
...
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







All times are GMT +1. The time now is 10:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com