PC Review


Reply
Thread Tools Rate Thread

Avoiding a hidden sheet

 
 
=?Utf-8?B?UmVwb3J0U21pdGg=?=
Guest
Posts: n/a
 
      30th Mar 2007
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.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      30th Mar 2007
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
 
Reply With Quote
 
=?Utf-8?B?UmVwb3J0U21pdGg=?=
Guest
Posts: n/a
 
      30th Mar 2007
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
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      30th Mar 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoiding an extra sheet when creating a pivot table SteveM Microsoft Excel Programming 3 28th Mar 2009 09:53 PM
I need my Hidden Rows to stay hidden when I print the sheet. =?Utf-8?B?Um9zYWxpZXdvbw==?= Microsoft Excel Misc 2 20th Jul 2006 07:51 PM
Avoiding sheet deletion by VBA =?Utf-8?B?UGFsaWtlRnJvbVNsb3Zha2lh?= Microsoft Excel Programming 2 1st Mar 2006 02:57 PM
how do i copy formula down columns avoiding hidden cells =?Utf-8?B?UEVURQ==?= Microsoft Excel Misc 1 14th Oct 2005 12:11 PM
Saving hidden data with a worksheet (preferably without using a hidden sheet) Aaron Queenan Microsoft Excel Programming 3 21st Jan 2004 04:39 PM


Features
 

Advertising
 

Newsgroups
 


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