View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
cereldine[_21_] cereldine[_21_] is offline
external usenet poster
 
Posts: 1
Default improvements in telling loop to stop


Do ' start loop
sYear = Ocell.Text ' this value will change on each loop
wb2.Activate
On Error Resume next
Set wsI = Worksheets(sYear) ''year to search for
On error Goto 0
If wsI Is Nothing Then Exit Do
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


I tried the above and it didn't work as expected, the loop picks up the
fact that sYear is blank and provides an error message stating an error
has occurred, it then breaks the loop but also the sub as well. In my
code i have some further things i would like to do after the loop which
this method bypasses. Thanks tho

I experimented with the resume next, on error goto 0 as you suggested
die_a_d previously and this also causes bizarre results, it just causes
the code to copy and paste a number of unrequired colmns before moving
on.


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