Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Run the macro until activeSheet.previous.Select = Sheet2

Hi,

I want a loop which will stop if the activesheet is "Sheet2" of the
workbook.

Regards

Heera
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Run the macro until activeSheet.previous.Select = Sheet2

Found = False
for sht in sheets
if sht.name = "Sheet2" then
Found = true
exit for
end if
next sht
if Found = true then
'enter your code here
end if

"Heera" wrote:

Hi,

I want a loop which will stop if the activesheet is "Sheet2" of the
workbook.

Regards

Heera

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run the macro until activeSheet.previous.Select = Sheet2

Try a construction like this...

Dim WS As Worksheet
.....
.....
For Each WS In Worksheets
If WS.Name = "Sheet2" Then
'
' You found Sheet2, so execute your code here
'
Exit For
End If
Next
......
......

Note the Exit For statement after your Sheet2 code... that stops the loop
from continuing on (you already found Sheet2, so there is no longer any need
to keep looping looking for it).

Rick


"Heera" wrote in message
...
Hi,

I want a loop which will stop if the activesheet is "Sheet2" of the
workbook.

Regards

Heera


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Run the macro until activeSheet.previous.Select = Sheet2

Thank you but I used this code.

Do While ActiveSheet.Name < "Sheet2"

My entire procedure

Loop
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
macro to print sheet2 without open sheet2 ramzi Excel Discussion (Misc queries) 1 January 28th 09 12:07 PM
ActiveSheet.name not returning Sheet1, Sheet2 Rebecca_SUNY Excel Programming 6 July 11th 08 02:43 PM
Select the ActiveSheet & the sheet next to it Dolphinv4 Excel Discussion (Misc queries) 1 December 11th 07 02:13 PM
ActiveSheet.Next.Select not working! Ron McCormick[_2_] Excel Programming 2 December 15th 03 12:42 PM
activesheet - select rows Rubble[_2_] Excel Programming 0 September 9th 03 03:06 AM


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