ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA equivalent of Javascript continue (https://www.excelbanter.com/excel-programming/350842-vba-equivalent-javascript-continue.html)

fazstp[_3_]

VBA equivalent of Javascript continue
 

Is there an equivalent of the continue used in javascript to skip a for
loop?

I have a number of if then conditions to be met and rather than nest
them I would prefer to skip to the next loop if the condition isn't
met.

ie:

For n = 1 to 10

If (condition1 = false) Then
' skip anything doesn't meet 1st criteria
' this is where I would use continue in javascript
End If

' If it gets to this point I know 1st condition has been met

If (condition2 = false) Then
' skip anything doesn't meet 2nd criteria
End If

' If it gets to this point I know 1st and 2nd conditions have been met

Next n


--
fazstp
------------------------------------------------------------------------
fazstp's Profile: http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=502732


Pierre Archambault

VBA equivalent of Javascript continue
 
Hi,

Try this:
---------------------------------------------------------------
For n = 1 to 10

If (condition1 = false) Then
Goto NextN
' skip anything doesn't meet 1st criteria
' this is where I would use continue in javascript
End If

' If it gets to this point I know 1st condition has been met

If (condition2 = false) Then
Goto NextN
' skip anything doesn't meet 2nd criteria
End If

' If it gets to this point I know 1st and 2nd conditions have been met

NextN: 'Don't forget the colon (:)

Next n
---------------------------------------------------------------

Pierre


"fazstp" a écrit dans
le message de ...

Is there an equivalent of the continue used in javascript to skip a for
loop?

I have a number of if then conditions to be met and rather than nest
them I would prefer to skip to the next loop if the condition isn't
met.

ie:

For n = 1 to 10

If (condition1 = false) Then
' skip anything doesn't meet 1st criteria
' this is where I would use continue in javascript
End If

' If it gets to this point I know 1st condition has been met

If (condition2 = false) Then
' skip anything doesn't meet 2nd criteria
End If

' If it gets to this point I know 1st and 2nd conditions have been met

Next n


--
fazstp
------------------------------------------------------------------------
fazstp's Profile:

http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=502732




Tim Williams

VBA equivalent of Javascript continue
 
for n=1 to 10

if condition1=true then
if condition2= true then
'do stuff
end if
end if

next n

Tim

--
Tim Williams
Palo Alto, CA


"fazstp" wrote in
message ...

Is there an equivalent of the continue used in javascript to skip a for
loop?

I have a number of if then conditions to be met and rather than nest
them I would prefer to skip to the next loop if the condition isn't
met.

ie:

For n = 1 to 10

If (condition1 = false) Then
' skip anything doesn't meet 1st criteria
' this is where I would use continue in javascript
End If

' If it gets to this point I know 1st condition has been met

If (condition2 = false) Then
' skip anything doesn't meet 2nd criteria
End If

' If it gets to this point I know 1st and 2nd conditions have been met

Next n


--
fazstp
------------------------------------------------------------------------
fazstp's Profile:

http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=502732





All times are GMT +1. The time now is 08:54 PM.

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