ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to stop a loop (https://www.excelbanter.com/excel-programming/317901-how-stop-loop.html)

L775

how to stop a loop
 
How do I stop iteration when it reaches the end of a group of occupied cells
filled with the same text (i.e. B277) in a column?

Thanks


Frank Kabel

how to stop a loop
 
Hi
exit for


--
Regards
Frank Kabel
Frankfurt, Germany

"L775" schrieb im Newsbeitrag
...
How do I stop iteration when it reaches the end of a group of

occupied cells
filled with the same text (i.e. B277) in a column?

Thanks



L775

how to stop a loop
 

I want it to stop at the end of the list. who does it know that the next
cell is empty so it will not error or use an empty cell.
the length of the list in a column or number of rows varies for different
groups that the routine or loop neet to operate on. thank you for your help.
I know there is a way of doing.



david mcritchie

how to stop a loop
 
To have the programming work similar to doubleclick on the fill handle
so that it copies down until the next cell is empty requires a Tom Ogilvy
solution.
http://google.com/groups?threadm=eZv...GP15.phx.g bl

The macro equivalent ( SUB ) to double-click.
Dim rng as Range
set rng = Range(cells(2,1),cells(2,1).End(xldown))
rng.offset(0,1).Formula = Cells(2,2).Formula

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"L775" wrote in message ...

I want it to stop at the end of the list. who does it know that the next
cell is empty so it will not error or use an empty cell.
the length of the list in a column or number of rows varies for different
groups that the routine or loop neet to operate on. thank you for your help.
I know there is a way of doing.





Steve Smallman

how to stop a loop
 
Hi,

how about

do until activecell.offset (0,1).value =""
'code
activecell.offset(1,0).select
Loop

Steve
"David McRitchie" wrote in message
...
To have the programming work similar to doubleclick on the fill handle
so that it copies down until the next cell is empty requires a Tom Ogilvy
solution.
http://google.com/groups?threadm=eZv...GP15.phx.g bl

The macro equivalent ( SUB ) to double-click.
Dim rng as Range
set rng = Range(cells(2,1),cells(2,1).End(xldown))
rng.offset(0,1).Formula = Cells(2,2).Formula

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"L775" wrote in message
...

I want it to stop at the end of the list. who does it know that the next
cell is empty so it will not error or use an empty cell.
the length of the list in a column or number of rows varies for different
groups that the routine or loop neet to operate on. thank you for your
help.
I know there is a way of doing.







david mcritchie

how to stop a loop
 
Wouldn't work same. A formula could be returning a null value,
Tom's code has no loop, much faster, and works same as
the worksheet function would for a selection from Column A.
Other columns would check the column to the left instead of
to the right.

BTW, changing the activecell is not a good practice within a macro
except upon exiting and only if that was the purpose of the macro.

However there are many ways to solve a problem and knowing
your data is always important.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Steve Smallman" wrote in message ...
Hi,

how about

do until activecell.offset (0,1).value =""
'code
activecell.offset(1,0).select
Loop

Steve
"David McRitchie" wrote in message
...
To have the programming work similar to doubleclick on the fill handle
so that it copies down until the next cell is empty requires a Tom Ogilvy
solution.
http://google.com/groups?threadm=eZv...GP15.phx.g bl

The macro equivalent ( SUB ) to double-click.
Dim rng as Range
set rng = Range(cells(2,1),cells(2,1).End(xldown))
rng.offset(0,1).Formula = Cells(2,2).Formula

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"L775" wrote in message
...

I want it to stop at the end of the list. who does it know that the next
cell is empty so it will not error or use an empty cell.
the length of the list in a column or number of rows varies for different
groups that the routine or loop neet to operate on. thank you for your
help.
I know there is a way of doing.









David

how to stop a loop
 
Hi L775,

At the top of the loop:
Do until activecell.value = ""

You did a post on 11/25/04 where you indicated that you might be interested
in a programmer to do freelance projects. Are you still interested?
.

Thanks

"L775" wrote:


I want it to stop at the end of the list. who does it know that the next
cell is empty so it will not error or use an empty cell.
the length of the list in a column or number of rows varies for different
groups that the routine or loop neet to operate on. thank you for your help.
I know there is a way of doing.




All times are GMT +1. The time now is 07:29 PM.

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