Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have an IF statement within a For Next loop.
How can I break out of an IF statement and move on to the next loo iteration -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"scain2004 <" wrote...
I have an IF statement within a For Next loop. How can I break out of an IF statement and move on to the next loop iteration? You could use GoTo, but it's likely there's a better way. If you post your code, someone here is likely to be able to suggest such a better way. -- To top-post is human, to bottom-post and snip is sublime. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In general, this appears to be a design issue. You didn't say nested if
statements, so the general approach: for i = 1 to 10 if condition then ' code to execute if condition is met end if Next -- Regards, Tom Ogilvy "scain2004 " wrote in message ... I have an IF statement within a For Next loop. How can I break out of an IF statement and move on to the next loop iteration? --- Message posted from http://www.ExcelForum.com/ |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It goes like this:
For i = 0 To counter ...some code... If For j = 0 To .... If ...some code ....break out to Next i ElseIf ...some code ...break out to Next i ElseIf ...some code End If Next j ElseIf For j = 0 To .... If ...some code ....break out to Next i ElseIf ...some code ...break out to Next i ElseIf ...some code End If Next j End If Next -- Message posted from http://www.ExcelForum.com |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
where you want to break out
exit for -- Regards, Tom Ogilvy "scain2004 " wrote in message ... It goes like this: For i = 0 To counter ..some code... If For j = 0 To .... If ..some code ...break out to Next i ElseIf ..some code ..break out to Next i ElseIf ..some code End If Next j ElseIf For j = 0 To .... If ..some code ...break out to Next i ElseIf ..some code ..break out to Next i ElseIf ..some code End If Next j End If Next i --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Breaking into Workbook_Open | Excel Discussion (Misc queries) | |||
Breaking links | Excel Worksheet Functions | |||
breaking during a macro run | Excel Discussion (Misc queries) | |||
Breaking Links | Excel Discussion (Misc queries) | |||
breaking out of a loop | Excel Programming |