ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Loops (https://www.excelbanter.com/excel-discussion-misc-queries/114415-loops.html)

[email protected]

Loops
 
Hi, I know how to use a For Next Loop but I'm having a problem with the
Do While and the Do Until loops. I want the macro to execute until the
cell on the left is blank. Can someone help?

Thanks

Chuck


Bob Phillips

Loops
 
Do Until Activecell.Offset(0,-1).Value = ""
'do some stuff
Activecell.Offset(1,0).Select
Loop

or

Do While Activecell.Offset(0,-1).Value < ""
'do some stuff
Activecell.Offset(1,0).Select
Loop

It is not really necessary to do the selecting, but that is another story.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ups.com...
Hi, I know how to use a For Next Loop but I'm having a problem with the
Do While and the Do Until loops. I want the macro to execute until the
cell on the left is blank. Can someone help?

Thanks

Chuck




[email protected]

Loops
 

Bob Phillips wrote:
Do Until Activecell.Offset(0,-1).Value = ""
'do some stuff
Activecell.Offset(1,0).Select
Loop

or

Do While Activecell.Offset(0,-1).Value < ""
'do some stuff
Activecell.Offset(1,0).Select
Loop

It is not really necessary to do the selecting, but that is another story.

--
HTH

Bob Phillips



Bob, Thanks a lot it worked great

Chuck

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ups.com...
Hi, I know how to use a For Next Loop but I'm having a problem with the
Do While and the Do Until loops. I want the macro to execute until the
cell on the left is blank. Can someone help?

Thanks

Chuck




All times are GMT +1. The time now is 12:24 PM.

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