ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Cycle through non-hidden pages only (https://www.excelbanter.com/excel-discussion-misc-queries/206611-cycle-through-non-hidden-pages-only.html)

Steve

Cycle through non-hidden pages only
 
I have a workbook with several hidden pages. I'm trying to write some vb code
that will cycle though the Visible pages and ignore those that are hidden.
Any help would be greatly appreciated.
Thanks Steve

Kevin B

Cycle through non-hidden pages only
 
The following code will not run, but hopefully it will point you in the
proper direction. Using the IF statement to determine whether or not
something happens to a particular worksheet in the current workbook:

Sub VisibleOnly()

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ThisWorkbook

For Each ws In wb.Worksheets
If ws.Visible Then
Do something here
End If
Next ws

Set ws = Nothing
Set wb = Nothing

End Sub

--
Kevin Backmann


"Steve" wrote:

I have a workbook with several hidden pages. I'm trying to write some vb code
that will cycle though the Visible pages and ignore those that are hidden.
Any help would be greatly appreciated.
Thanks Steve


Don Guillett

Cycle through non-hidden pages only
 
Sub doifnothiddensheet()
For Each ws In Worksheets
If ws.Visible = True Then 'do this
Next ws
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Steve" wrote in message
...
I have a workbook with several hidden pages. I'm trying to write some vb
code
that will cycle though the Visible pages and ignore those that are hidden.
Any help would be greatly appreciated.
Thanks Steve



Earl Kiosterud

Cycle through non-hidden pages only
 
Steve,

Try this:

Sub CycleSheets()
Dim sheett As Worksheet
For Each sheett In Sheets()
If sheett.Visible Then

' your code here

End If
Next sheett
End Sub

--
Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com
-----------------------------------------------------------------------
"Steve" wrote in message
...
I have a workbook with several hidden pages. I'm trying to write some vb code
that will cycle though the Visible pages and ignore those that are hidden.
Any help would be greatly appreciated.
Thanks Steve




Steve

Cycle through non-hidden pages only
 
Thanks Kevin
Works great!
Steve

"Kevin B" wrote:

The following code will not run, but hopefully it will point you in the
proper direction. Using the IF statement to determine whether or not
something happens to a particular worksheet in the current workbook:

Sub VisibleOnly()

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ThisWorkbook

For Each ws In wb.Worksheets
If ws.Visible Then
Do something here
End If
Next ws

Set ws = Nothing
Set wb = Nothing

End Sub

--
Kevin Backmann


"Steve" wrote:

I have a workbook with several hidden pages. I'm trying to write some vb code
that will cycle though the Visible pages and ignore those that are hidden.
Any help would be greatly appreciated.
Thanks Steve


Steve

Cycle through non-hidden pages only
 
works just fine
Thanks
Steve

"Don Guillett" wrote:

Sub doifnothiddensheet()
For Each ws In Worksheets
If ws.Visible = True Then 'do this
Next ws
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Steve" wrote in message
...
I have a workbook with several hidden pages. I'm trying to write some vb
code
that will cycle though the Visible pages and ignore those that are hidden.
Any help would be greatly appreciated.
Thanks Steve




Steve

Cycle through non-hidden pages only
 
Thanks to all. Code works great
Steve

"Earl Kiosterud" wrote:

Steve,

Try this:

Sub CycleSheets()
Dim sheett As Worksheet
For Each sheett In Sheets()
If sheett.Visible Then

' your code here

End If
Next sheett
End Sub

--
Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com
-----------------------------------------------------------------------
"Steve" wrote in message
...
I have a workbook with several hidden pages. I'm trying to write some vb code
that will cycle though the Visible pages and ignore those that are hidden.
Any help would be greatly appreciated.
Thanks Steve






All times are GMT +1. The time now is 11:41 AM.

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