ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop to Next item in For Next on Condition (https://www.excelbanter.com/excel-programming/308679-loop-next-item-next-condition.html)

[email protected]

Loop to Next item in For Next on Condition
 
Is there a way to do the following:

For i = 1 to iEnd
If Array(i) = Value Then
Next i
Else
For j = 1 to jEnd
..
..
..
Next j
End If
Next i

I know I can't have the Next i in there twice.


Bob Umlas[_3_]

Loop to Next item in For Next on Condition
 
For i=1 to iEnd
If Array(i) = abc then goto 1
...
Else
For j=1 to jEnd
...
Next j
End if
1:
Next i

Bob Umlas
Excel MVP

" wrote in message
...
Is there a way to do the following:

For i = 1 to iEnd
If Array(i) = Value Then
Next i
Else
For j = 1 to jEnd
.
.
.
Next j
End If
Next i

I know I can't have the Next i in there twice.




Tom Ogilvy

Loop to Next item in For Next on Condition
 
i = lbound(array)
do while i <= ubound(array)
if array(i) = array1(kk) then
j = i
do while array() = array1(kk)
j = j + 1
loop
msgbox "for value " & array1(kk) & vbnewline & _
"Start position is " & i & vbNewline
"End position is " & j
exit do
Loop

--
Regards,
Tom Ogilvy


" wrote in message
...
Is there a way to do the following:

For i = 1 to iEnd
If Array(i) = Value Then
Next i
Else
For j = 1 to jEnd
.
.
.
Next j
End If
Next i

I know I can't have the Next i in there twice.





All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com