Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default how to break out of an if statement and continue to loop

I'm really stuck. I grab a value from one page and go to another page to
find a match. All is well unless I can't find a match. I need to break out
of the inner loop and continue the outer. Here is my code. I can't figure
out how to break out yet continue execution. Thanks
(outer loop is here)
Do Until StrComp(destin_unit, source_unit) < 0
If cntr2 < text_max_rows Then
cntr2 = cntr2 + 1
destin_unit = Cells(cntr2, 1)
Else
cntr2 = cntr3 + 1
'I need to break here and continue the outer loop
End If
Loop
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default how to break out of an if statement and continue to loop

Replace: 'I need to break here and continue the outer loop
With: Exit Do

Hth,
Merjet

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default how to break out of an if statement and continue to loop

Do you want something like this?

Sub demo()
For i = 1 To 100
greatescape = False
Do Until (StrComp(destin_unit, source_unit) < 0) Or greatescape = True
If cntr2 < text_max_rows Then
cntr2 = cntr2 + 1
destin_unit = Cells(cntr2, 1)
Else
cntr2 = cntr3 + 1
greatescape = True
End If
Loop
End Sub

--
Gary's Student
gsnu200705


"Darren" wrote:

I'm really stuck. I grab a value from one page and go to another page to
find a match. All is well unless I can't find a match. I need to break out
of the inner loop and continue the outer. Here is my code. I can't figure
out how to break out yet continue execution. Thanks
(outer loop is here)
Do Until StrComp(destin_unit, source_unit) < 0
If cntr2 < text_max_rows Then
cntr2 = cntr2 + 1
destin_unit = Cells(cntr2, 1)
Else
cntr2 = cntr3 + 1
'I need to break here and continue the outer loop
End If
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
Break out of a loop in Excel2007? Don Excel Discussion (Misc queries) 8 May 4th 09 09:48 PM
Is there a break statement in VBA Shani Excel Programming 5 April 14th 06 03:52 PM
How to continue loop after deleting row? [email protected] Excel Programming 4 April 10th 06 01:55 PM
continue statement in a loop rozner Excel Programming 4 August 2nd 05 03:30 PM
How do you test to break out of a find loop? Henry Stock Excel Programming 4 February 26th 04 11:15 PM


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