View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Help with Address property in nested loops

Once you are past all the values in your search area, you are in the inner
loop and it continues to go since the only condition to stop it is if it
finds a value. I added a condition so it will jump out if the activecell
gets to 500.


Sub TesterAA()
Application.Goto reference:=Worksheets("newdata").Range("newlist")

Do Until ActiveCell.Row = 500

'finds the first cell that contains data
Do While ActiveCell.Value = "" And ActiveCell.Row <= 500
Application.ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Select
Loop

if ActiveCell.Value = "" then exit sub
contents = ActiveCell.Value
Location = ActiveCell.Address

'goes to destination location
Application.Goto reference:=Worksheets("Comments Results").Range("Q5list")

'finds the first blank cell in column
Do Until ActiveCell.Value = ""
Application.ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Select
Loop

'inserts the value and returns to last location to begin again
ActiveCell.Value = contents
Application.Goto reference:=Worksheets("newdata").Range(Location)
Application.ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Select

Loop


End Sub





--
Regards,
Tom Ogilvy

"Jill E" wrote in message
.. .
I tried the suggestion made by Tom using the row property instead, but I
can't get it to work in the context of the loops. Here is the actual
code...can you take a quick look?


'goes to starting cell
Application.Goto reference:=Worksheets("newdata").Range("newlist")

Do Until ActiveCell.Row = 500

'finds the first cell that contains data
Do While ActiveCell.Value = ""
Application.ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Select
Loop

contents = ActiveCell.Value
Location = ActiveCell.Address

'goes to destination location
Application.Goto reference:=Worksheets("Comments Results").Range("Q5list")

'finds the first blank cell in column
Do Until ActiveCell.Value = ""
Application.ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Select
Loop

'inserts the value and returns to last location to begin again
ActiveCell.Value = contents
Application.Goto reference:=Worksheets("newdata").Range(Location)
Application.ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Select

Loop

Any suggestions would be very welcome!

"Tom Ogilvy" wrote in message
...
Do Until ActiveCell.row = 400
Do whileActiveCell.value = ""
ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Select
Loop


bla bla bla

Loop

hope you have something in the outer loop that will keep incrementing

the
activeCell

--
Regards,
Tom Ogilvy

"Jill E" wrote in message
.. .
Hi,

I'm trying to create a macro that loops through some code but stops when

the
cell address is u400, and within it another loop that looks for a blank
cell. I can't get the outer loop to recognize the limit of u400. I'm

tried
using activecell.value instead, but neither seem to recognize the limit.

So it looks something like this:

Do Until ActiveCell.Address = "a100"

Do whileActiveCell.value = ""
ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Select
Loop


bla bla bla

Loop

When I run this, it does loop back to the beginning but doesn't stop

until
it reaches the end of the file, thus producing an error. I've tried to
return the address using the address property and that was successful,

but
when I tried to specify the address in the do until statement, I

couldn't
get it to work...and naturally I can't find any documentation!

Please help!

Thanks,
JillE