Exit to the beginning of For Next loop

C

CousinExcel

Hi,

For i=1 to 5
if .... then
....
....
GO TO THE BEGINNING OF FOR NEXT LOOP
end if
....
....
next i

What should I say to mean "GO TO THE BEGINNING OF FOR NEXT LOOP" above (if I
can).

Thanks and regards,

Cousin Excel
 
M

Mike H

Hi,

In the If statement you can test for a condition then if satisfied exit the
for next loop

For i = 1 To 5
if my condition is met then
Exit For
End If

Next i
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
G

Gary''s Student

Sub demo()
For i = 1 To 5
v = Cells(i, 1).Value
If v > 10 Then
Cells(i, 2).Value = "Big"
GoTo skiput
End If
Cells(i, 2).Value = "Little"
skiput:
Next i
End Sub
 
C

CousinExcel

Many thanks.
CousinExcel


Gary''s Student said:
Sub demo()
For i = 1 To 5
v = Cells(i, 1).Value
If v > 10 Then
Cells(i, 2).Value = "Big"
GoTo skiput
End If
Cells(i, 2).Value = "Little"
skiput:
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top