View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Go straight to next value in a For... Next loop

What you have (without the goto of course) does just that, because the fact
that c.value < 100 means that all of the code in the Else portion does not
get executed, so the next statement is EndIf, which drops into the Next.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"IanKR" wrote in message
...
Is there a way of going straight to the next value in a For / Next loop,
having tested the current value? I need to do something like this (for
example):

Dim c as Range
For each c in Selection.Cells
If c.Value < 100 Then
Goto Next c '<<<<< I know this is illegal, but it illustrates
what I want to do!
Else
{statements where c.Value = 100}
...
...
End If
Next c

I don't want to Exit For, I just want it to effectively ignore the current
instance of c and move onto the next. I've tried "Next c" but it generates
a compile error.

Thanks in advance.

Ian