Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Avoiding a hidden sheet

I currently have code to loop through the number of sheets in a workbook.....

Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum))
For Each sh In mybook.Worksheets

......but I need to loop 1 less than the total number of sheets to avoid a
hidden sheet in the same workbook - in other words, I need something like.....
For Each [sh-1] In mybook.Worksheets..........

Any suggestions?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Avoiding a hidden sheet

Just avoid the hidden sheets.

For Each sh In mybook.Worksheets
if sh.visible = xlsheetvisible then
'do what you want
end if
next sh



ReportSmith wrote:

I currently have code to loop through the number of sheets in a workbook.....

Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum))
For Each sh In mybook.Worksheets

.....but I need to loop 1 less than the total number of sheets to avoid a
hidden sheet in the same workbook - in other words, I need something like.....
For Each [sh-1] In mybook.Worksheets..........

Any suggestions?

Thanks in advance.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Avoiding a hidden sheet

Thanks Dave. When I saw your post, I thought "Duh" - I should've known that
- but I've been staring at this code for too long and don't know where I am
anymore.

I'll try it out. Again, thanks.

"Dave Peterson" wrote:

Just avoid the hidden sheets.

For Each sh In mybook.Worksheets
if sh.visible = xlsheetvisible then
'do what you want
end if
next sh



ReportSmith wrote:

I currently have code to loop through the number of sheets in a workbook.....

Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum))
For Each sh In mybook.Worksheets

.....but I need to loop 1 less than the total number of sheets to avoid a
hidden sheet in the same workbook - in other words, I need something like.....
For Each [sh-1] In mybook.Worksheets..........

Any suggestions?

Thanks in advance.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Avoiding a hidden sheet

Sometimes, the extra set of eyes is enough to get you going again.

ReportSmith wrote:

Thanks Dave. When I saw your post, I thought "Duh" - I should've known that
- but I've been staring at this code for too long and don't know where I am
anymore.

I'll try it out. Again, thanks.

"Dave Peterson" wrote:

Just avoid the hidden sheets.

For Each sh In mybook.Worksheets
if sh.visible = xlsheetvisible then
'do what you want
end if
next sh



ReportSmith wrote:

I currently have code to loop through the number of sheets in a workbook.....

Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum))
For Each sh In mybook.Worksheets

.....but I need to loop 1 less than the total number of sheets to avoid a
hidden sheet in the same workbook - in other words, I need something like.....
For Each [sh-1] In mybook.Worksheets..........

Any suggestions?

Thanks in advance.


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i paste rows/columns avoiding hidden rows/columns perezli Excel Discussion (Misc queries) 1 January 30th 09 03:58 PM
I need my Hidden Rows to stay hidden when I print the sheet. Rosaliewoo Excel Discussion (Misc queries) 2 July 20th 06 07:51 PM
Avoiding sheet deletion by VBA PalikeFromSlovakia Excel Programming 2 March 1st 06 02:57 PM
how do i copy formula down columns avoiding hidden cells PETE Excel Discussion (Misc queries) 1 October 14th 05 12:11 PM
Saving hidden data with a worksheet (preferably without using a hidden sheet) Dick Kusleika[_3_] Excel Programming 2 January 21st 04 04:39 PM


All times are GMT +1. The time now is 03:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"