I was wondering if the was a way to skip numbers in a counting
sequence. For example:
For i = 1 to 10
next i
Is there a way to skip over 5, 6, 7 so the count could be
1, 2, 3, 4, 8, 9, 10?
Thanks in advance.
Sandy
I was wondering if the was a way to skip numbers in a counting
sequence. For example:
For i = 1 to 10
next i
Is there a way to skip over 5, 6, 7 so the count could be
1, 2, 3, 4, 8, 9, 10?
Thanks in advance.
Sandy
Hi Sandy
Try this:
For i = 1 to 10
If i <> 5 Or i <> 6 Or i <> 7 Then
yourprocedure
End if
Next
Regards
Steve
Hi Sandy
Probably better is:
If i < 5 Or i > 7 Then...
Regards
Steve
Just check?
For i = 1 to 10
select case i
case 5,6,7
'do nothing
case else
'do what you want
end select
next i
Sandy wrote:
>
> I was wondering if the was a way to skip numbers in a counting
> sequence. For example:
>
> For i = 1 to 10
> next i
>
> Is there a way to skip over 5, 6, 7 so the count could be
>
> 1, 2, 3, 4, 8, 9, 10?
>
> Thanks in advance.
>
> Sandy
--
Dave Peterson
Many ways, such as
For i = 1 to 10
If i > 4 And i < 8 Then
... your bits
End If
next i
or
For i = 1 to 10
... your bits
If i = 4 Then i = 7
Next i
and many others I am sure
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"Sandy" <[email protected]> wrote in message
news:[email protected]...
> I was wondering if the was a way to skip numbers in a counting
> sequence. For example:
>
> For i = 1 to 10
> next i
>
> Is there a way to skip over 5, 6, 7 so the count could be
>
> 1, 2, 3, 4, 8, 9, 10?
>
> Thanks in advance.
>
> Sandy
>
for i = 1 to 10
if i < 5 or i > 7 then
end if
Next
--
Regards,
Tom Ogilvy
"Sandy" wrote:
> I was wondering if the was a way to skip numbers in a counting
> sequence. For example:
>
> For i = 1 to 10
> next i
>
> Is there a way to skip over 5, 6, 7 so the count could be
>
> 1, 2, 3, 4, 8, 9, 10?
>
> Thanks in advance.
>
> Sandy
>
>
Since i is a variable couldn't you...
For i = 1 to 10
if i=4 then i=7
Next i
Jesse
well..a simple code, so many answers..Jesse Wins :o)
Cheers.....
Most consider it bad form to change the index variable within a loop.
--
Regards,
Tom Ogilvy
"vikas.bhandari" wrote:
>
> well..a simple code, so many answers..Jesse Wins :o)
>
> Cheers.....
>
>
> --
> vikas.bhandari
> ------------------------------------------------------------------------
> vikas.bhandari's Profile: http://www.excelforum.com/member.php...o&userid=33276
> View this thread: http://www.excelforum.com/showthread...hreadid=530938
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks