ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loops question (https://www.excelbanter.com/excel-programming/385342-loops-question.html)

AVB Over My Head

Loops question
 
How can a make a loop in a macro until A2 = blank or "". Where can I
put it in the code, in the beginning of the code or the end of it?


Jean-Yves[_2_]

Loops question
 
HI,

3 possiblitis :
1. Always execute one
Do
......
lopp while cond=true
2.Execute only if
Do while cond=True
.....
loop
3Variable
Do
..some code
'test
if cond=ture then exit do
some code
Loop
Regards
JY

"AVB Over My Head" wrote in message
oups.com...
How can a make a loop in a macro until A2 = blank or "". Where can I
put it in the code, in the beginning of the code or the end of it?




chad

Loops question
 
you'll need to start the loop where you want it to start and end it where you
want to end it (obvious statement). i'd use code similar to the following in
your code:

do
do while range("A2")<""
'here's your looped code
'at the end of your code where you want the loop to end
loop
loop until range("A2")=""

make sure you're doing something with range A2 in this loop or else it will
run forever.

hope this helps,
chad


"AVB Over My Head" wrote:

How can a make a loop in a macro until A2 = blank or "". Where can I
put it in the code, in the beginning of the code or the end of it?




All times are GMT +1. The time now is 08:07 AM.

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