ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   newbie: stop a FOR NEXT loop (https://www.excelbanter.com/excel-programming/279320-newbie-stop-next-loop.html)

Mike H[_7_]

newbie: stop a FOR NEXT loop
 
how can I jump out of a for next loop before I get to the top of the series
of numbers?



Jeroen Schouten

newbie: stop a FOR NEXT loop
 
If <condition Exit For


"Mike H" wrote in message
...
how can I jump out of a for next loop before I get to the top of the

series
of numbers?





Frank Isaacs

newbie: stop a FOR NEXT loop
 
Check out Exit in the online help; it's used for this situation (Exit For)
as well as others (Exit Do, Exit Sub, Exit Function, etc.).
--
HTH -

-Frank Isaacs
Dolphin Technology Corp.
http://vbapro.com


"Mike H" wrote in message
...
how can I jump out of a for next loop before I get to the top of the

series
of numbers?





Chrissy[_4_]

newbie: stop a FOR NEXT loop
 
Rethink your loop control.

Maybe you should not be using a for next loop - maybe a do while
loop would be better.

Chrissy.



"Mike H" wrote in message ...
how can I jump out of a for next loop before I get to the top of the series
of numbers?





Tom Ogilvy

newbie: stop a FOR NEXT loop
 
for each cell in Range("A1:A200")
if isempty cell then exit for
' code to execute
Next


for i = 1 to 1000
if [test condition] then exit for
' code to execute
Next i

--
Regards,
Tom Ogilvy

Mike H wrote in message
...
how can I jump out of a for next loop before I get to the top of the

series
of numbers?






All times are GMT +1. The time now is 09:00 AM.

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