For/Loop skipping one value in loop only
Except that the "purists" will tell you that the variable used in a For/Next
loop should be modified ONLY by the NEXT statement. If you adhere to those
"rules", Matt's solution is what is needed.
On Thu, 6 Jan 2005 08:25:02 -0800, "David"
wrote:
This really does not make any diff, maybe you are trying to increment i from
3 to 5? In that case instead of SkipDow put i = i +1?
Sub SkipIT()
myvar = True
For i = 1 To 6
If myvar = True Then
If i = 3 Then
GoTo SkipDown
Else
'do my code
End If
End If
SkipDown:
Next i
End Sub
"Matt Jensen" wrote:
G'day guys and girls
Just a quick question, more general programming than VBA specific, and one
that I haven't had to deal with before in any programming.
Example (pseudo code):
For i = 1 to 6
if myvar = true then
if i = 3 then
skip to next i
else
'do my code
end if
end if
Next i
So, in simple terms, I want to skip my processing code if i = 3.
However I included the "if myvar = true" code because I only want to skip
i=3 if a certain condition elsewhere in my workbook is true.
What's the best way to go about this?
Thanks very much
Matt
|