LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default improvements in telling loop to stop


Hi, i have designed a loop statement that looks to a external workbook
to retrieve data. This workbook(wb2) contains sheets named after years
from 1992 to 2003. Each Worksheet contains information for about 120
different catergories. Within my original workbook(wb1) 15 or so of the
catergories have there own worksheet, my code will then open up wb2 and
the first sheet (1992) and return the data series for the particular
catergory, it then moves on to next year (1993) and so on. At the
moment i'm telling it exactly how to stop e.g loop until iCell =
"2004"

I would like to improve this to say something along the lines of if
worksheet(myVariable called sYear) is nothing then exit the loop. I've
been experimenting with

Do ' start loop
sYear = Ocell.Text ' this value will change on
each loop
wb2.Activate
Set wsI = Worksheets(sYear) ''year to search
for
wsI.Activate ' make the intermediate sheet
active
Range("A3").Select
wsI.Cells.Find(sIO).Select '

Set Ocell = Ocell.Offset(0, 1) ' go to next row
in series
Loop Until wsI Is Nothing

Unfortunatly this effort only makes it as far as the line in red e.g it
will loop until sYear = 2005 and then stops as no worksheet is called
2005 thus producing error and breaking the loop anyway.
Can anyone see an easy approach around what i'm trying to do? thanks


--
cereldine
------------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=535958

 
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
telling range when to stop. cereldine[_16_] Excel Programming 2 April 13th 06 12:11 PM
Hot key to stop a LOOP joopdog[_3_] Excel Programming 5 February 9th 06 06:51 PM
how to stop a loop L775 Excel Programming 6 November 29th 04 08:37 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM
newbie: stop a FOR NEXT loop Mike H[_7_] Excel Programming 4 October 11th 03 04:47 PM


All times are GMT +1. The time now is 06:27 AM.

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

About Us

"It's about Microsoft Excel"