Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Looping through sheets

I have code (Excel 2000) that loops through all the visible sheets in a
workbook. Problem is, when the code gets to the "next.sh" line, the next
worksheet is not selected.

For Each sh In mybook.Worksheets
if sh.visible = xlsheetvisible then
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Looping through sheets

Why do you want to select the sheets? Using worksheet and range objects
directly is faster and easier to maintain.

However, if you really want to select, then

For Each sh in mybook.Worksheets
If sh.Visible = xlSheetVisible Then
sh.Select
'...
End If
Next sh


In article ,
ReportSmith wrote:

I have code (Excel 2000) that loops through all the visible sheets in a
workbook. Problem is, when the code gets to the "next.sh" line, the next
worksheet is not selected.

For Each sh In mybook.Worksheets
if sh.visible = xlsheetvisible then
.
...............
.
end if
next sh

Any ideas?

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Looping through sheets

try this:

For Each sh In mybook.Worksheets
If sh.Visible = True Then
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Looping through sheets

I don't think my earlier reply was received...but in any case...I need to do
a lot of consolidating of non-standardized data on every sheet, so I have
nested loops and if..thens. I tried your suggestion and it worked.

Thank you.

"JE McGimpsey" wrote:

Why do you want to select the sheets? Using worksheet and range objects
directly is faster and easier to maintain.

However, if you really want to select, then

For Each sh in mybook.Worksheets
If sh.Visible = xlSheetVisible Then
sh.Select
'...
End If
Next sh


In article ,
ReportSmith wrote:

I have code (Excel 2000) that loops through all the visible sheets in a
workbook. Problem is, when the code gets to the "next.sh" line, the next
worksheet is not selected.

For Each sh In mybook.Worksheets
if sh.visible = xlsheetvisible then
.
...............
.
end if
next sh

Any ideas?

Thanks.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Looping through sheets

Thanks for the suggestion. I tried what the earlier post recommended and it
worked. It's nice to know there are folks out there that are knowledgeable
and willing to assist.

Again, thanks.

"JLGWhiz" wrote:

try this:

For Each sh In mybook.Worksheets
If sh.Visible = True Then
.
...............
.
End If
Next sh


"ReportSmith" wrote:

I have code (Excel 2000) that loops through all the visible sheets in a
workbook. Problem is, when the code gets to the "next.sh" line, the next
worksheet is not selected.

For Each sh In mybook.Worksheets
if sh.visible = xlsheetvisible then
.
...............
.
end if
next sh

Any ideas?

Thanks.

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
Looping thru Sheets without activating Myles[_19_] Excel Programming 10 December 30th 05 04:05 PM
Looping through Sheets Jim Thomlinson[_3_] Excel Programming 3 September 25th 04 03:48 AM
Looping through Sheets dalejrstwin Excel Programming 0 September 24th 04 06:43 PM
Looping through sheets Eric[_7_] Excel Programming 1 July 24th 03 04:45 PM


All times are GMT +1. The time now is 11:59 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"