For To Next loop

  • Thread starter Thread starter uno@korsmaa
  • Start date Start date
U

uno@korsmaa

Dear professionals

Does the For ...To .. Next loop have a syntax where I could run 2
different number ranges in the same loop (will illustrate my question by a
fake "code").

For n = 1 To 10 And For n = 21 To 30
... do something
Next n

I guess I could inside the loop, use an IF condition at the beginning and
let the loop ignore part of the numbers, but maybe there is a direct way
also.
 
Hi Uno,

You asked this two days ago and received a detailed response from JE
McGimpsey:

http://tinyurl.com/3lran

You should stay in the same thread and. if JE's response was inappropriate
to your needs, explained that there.

Otherwise you threads and may well cause respondents to waste time
duplicating replies.
 
Otherwise you threads ...

Otherwise you risk fragmenting threads ...
 
Hi Norman

I am sorry but the link you sent me does not open any page, and I can still
not find the answer you were talking about in my Outlook Express threads.

I was not trying to cause any trouble I just didn't see anyone answering my
question , so I posted it again in hope that maybe this time someone would
notice and respond to it. Now I can not find it any more. What should I do
now?

rgs
Uno

PS
Why don't I see all the threads from Outlook Express and have to go to a
webpage?
 
Hi Uno,

This was J.E's reply:
===============>> START
From: JE McGimpsey ([email protected])
Subject: Re: 2 questions

Newsgroups: microsoft.public.excel.programming
Date: 2004-09-13 10:09:48 PST


1) See the answer to Sheldon's "Worksheet Protection" thread.

2) One way:

For n = 1 To 30
If n <= 10 Or n>=21
'... do this
End If
Next n

an alternate is to adjust n within the loop, but I don't recommend it on
general good programming principles:

For n = 1 To 30
'...do this
If n = 10 Then n = 20
Next n

Doing a null loop as in the first example won't take more than a few
microseconds.
===============>> END
 

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

Back
Top