ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why doesn't Selection.End(xlDown).Select always work? (https://www.excelbanter.com/excel-programming/305846-re-why-doesnt-selection-end-xldown-select-always-work.html)

Tom Ogilvy

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.





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

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