M
Mike
Hi everyone,
Can someone please refer me to an example on how to use WHILE and LOOP
in Excel's VBA?
Thanks,
Mike
Can someone please refer me to an example on how to use WHILE and LOOP
in Excel's VBA?
Thanks,
Mike
Hi everyone,
Can someone please refer me to an example on how to use WHILE and LOOP
in Excel's VBA?
Thanks,
Mike
Mike said:Can someone please refer me to an example on how
to use WHILE and LOOP in Excel's VBA?
Mike said:Can someone please refer me to an example on how
to use WHILE and LOOP in Excel's VBA?
In VBA Help, type "while wend statement" and "do loop statement" without
quotes, and you will get lots of information. A few simple examples.....
x = 1
While x <= y
[...some statements...]
x = x + 1
Wend
x = 1
Do While x <= y
[...some statements...]
x = x + 1
Loop
x = 1
Do Until x > y
[...some statements...]
x = x + 1
Loop
x = 1
Do
[...some statements...]
x = x + 1
Loop While x <= y
x = 1
Do
[...some statements...]
Loop Until x > y
The first 3 are equivalent to:
For x = 1 to y
[...some statements...]
Next
In VBA Help, type "while wend statement" and "do loop statement" without
quotes, and you will get lots of information. A few simple examples.....x = 1
While x <= y
[...some statements...]
x = x + 1
Wendx = 1
Do While x <= y
[...some statements...]
x = x + 1
Loopx = 1
Do Until x > y
[...some statements...]
x = x + 1
Loopx = 1
Do
[...some statements...]
x = x + 1
Loop While x <= yx = 1
Do
[...some statements...]
Loop Until x > yThe first 3 are equivalent to:For x = 1 to y
[...some statements...]
Next
What if you have two or more conditions instaed of one?- Hide quoted text-
- Show quoted text -
In VBA Help, type "while wend statement" and "do loop statement" without
quotes, and you will get lots of information. A few simple examples.....x = 1
While x <= y
[...some statements...]
x = x + 1
Wendx = 1
Do While x <= y
[...some statements...]
x = x + 1
Loopx = 1
Do Until x > y
[...some statements...]
x = x + 1
Loopx = 1
Do
[...some statements...]
x = x + 1
Loop While x <= yx = 1
Do
[...some statements...]
Loop Until x > yThe first 3 are equivalent to:For x = 1 to y
[...some statements...]
Next
What if you have two or more conditions instaed of one?- Hide quoted text-
- Show quoted text -
Mike said:It is not exactly plain WHILE/Loop. Let me write
you how I have the While Loop thing:
WHILE( ( PlnHrznTop <= CARD(ts))
AND Continue <> 0)),
!! t is the first time period in the upcoming solve
LOOP( t with condition that (ORD(t) = PlnHrznTop),
Mike said:My WHILE/LOOP structure is as follows:
WHILE condition1 and condition2
LOOP over t while condition3 as below:
WHILE( PlnHrznTop <= ts
AND Continue <> 0),
LOOP( t while (ORD(t) = PlnHrznTop),
Mike said:LOOP over t while condition3 as below:
WHILE( PlnHrznTop <= ts
AND Continue <> 0),
LOOP( t while (ORD(t) = PlnHrznTop),
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.