Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Looping Thru Worksheets

I have a chunk of code that I would like to run thru on only certain
worksheets. How do I loop thru say only Sheets 2-6?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Looping Thru Worksheets

Worksheets are numbered from left to right regardless of their names.


Method One:

for i = 2 to 6
sheets(i).select
<Your Code
next i


Method Two (preferred due to unknowns such as hidden sheets):

for i = 2 to 6
sheets("Sheet" & i).select
<Your Code
next i


HTH,
Paul

"Jay" wrote in message
...
I have a chunk of code that I would like to run thru on only certain
worksheets. How do I loop thru say only Sheets 2-6?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Looping Thru Worksheets

For Each Sh In
Worksheets(Array("Sheet2","Sheet3","Sheet4","Sheet 5","Sheet6"))
'do something
Next sh

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jay" wrote in message
...
I have a chunk of code that I would like to run thru on only certain
worksheets. How do I loop thru say only Sheets 2-6?



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
Worksheets looping. Bob Phillips Excel Programming 0 December 6th 06 10:38 AM
Looping through Worksheets Steve Excel Programming 7 July 12th 05 07:56 PM
Looping through Worksheets Kirk P. Excel Programming 1 February 7th 05 05:14 PM
looping through worksheets Alex ekster Excel Programming 1 July 21st 03 03:16 AM
looping through worksheets alex Excel Programming 0 July 20th 03 06:43 PM


All times are GMT +1. The time now is 07:08 AM.

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"