View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Why doesn't Selection.End(xlDown).Select always work?

If you can select the cell and manually do End then hit the down arrow key
and it works, it should work with code.

This will stop at the last contiguous cell that is not empty.

It sounds like some of the cells maybe non-empty, but look empty.
If that is the case, you may have to loop - however, you might be able to
reduce the amout of looping with

Dim rng as Range
set rng = cells(rows.count,1).End(xlup)
do while rng.Text = ""
set rng = rng.offset(-1,0)
Loop
rng.Select

--
Regards,
Tom Ogilvy

"Andy" wrote in message
...
Hi,
I am trying to get the next free row using
Selection.End(xlDown).Select
Sometimes it seems to work, sometimes not.
Is there something else I need to know about this? I've currently given up

and am using a do look looking for the next emply cell, but its a bit of a
fudge, and won't win any 'pretty code' contests!

Any help would be appreciated.
Many thanks in advance.