ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For To Next loop (https://www.excelbanter.com/excel-programming/310080-next-loop.html)

uno@korsmaa

For To Next loop
 
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.

-----------------------------------
All the best, and thanks in advance.
Uno Kõrsmaa




Norman Jones

For To Next loop
 
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.

---
Regards,
Norman



"uno@korsmaa" wrote in message
...
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.

-----------------------------------
All the best, and thanks in advance.
Uno Kõrsmaa






Norman Jones

For To Next loop
 
Otherwise you threads ...

Otherwise you risk fragmenting threads ...

---
Regards,
Norman



"Norman Jones" wrote in message
...
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.

---
Regards,
Norman



"uno@korsmaa" wrote in message
...
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.

-----------------------------------
All the best, and thanks in advance.
Uno Kõrsmaa








uno@korsmaa

For To Next loop
 
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?





"Norman Jones" wrote in message
...
Otherwise you threads ...


Otherwise you risk fragmenting threads ...

---
Regards,
Norman



"Norman Jones" wrote in message
...
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.

---
Regards,
Norman



"uno@korsmaa" wrote in message
...
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.

-----------------------------------
All the best, and thanks in advance.
Uno Kõrsmaa










Norman Jones

For To Next loop
 
Hi Uno,

This was J.E's reply:
=============== START
From: JE McGimpsey )
Subject: 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

---
Regards,
Norman



"uno@korsmaa" wrote in message
...
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?





"Norman Jones" wrote in message
...
Otherwise you threads ...


Otherwise you risk fragmenting threads ...

---
Regards,
Norman



"Norman Jones" wrote in message
...
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.

---
Regards,
Norman



"uno@korsmaa" wrote in message
...
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.

-----------------------------------
All the best, and thanks in advance.
Uno Kõrsmaa













All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com