View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default "Move to bottom of range"

Select empty cell after last used cell in col A
Range("A" & Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1).Select


The above can be shortened to this...

Cells(Rows.Count, "A").End(xlUp).Offset(1).Select


Select empty cell in Col A below the last use cell on worksheet
Range("A" & Cells.SpecialCells(xlLastCell).Row + 1).Select


As Ron points out in the article he linked to, SpecialCells(xlLastCell) can
give you the wrong cell reference under certain circumstances. If you are
looking for a second method, though, then here is an alternative which will
work...

Columns("A").Find("*", , xlFormulas, , xlRows, xlPrevious).Offset(1).Select


It should be noted that both of the methods I posted find the empty cell
after the last cell with a value or formula EVEN IF that formula is
displaying the empty cell. If one would want to find the empty **looking**
cell (that is, the cell that is either empty or displaying the empty string)
located after the last displayed, non-empty value, you could use this last
method using xlValues in place of xlFormulas...

Columns("A").Find("*", , xlValues, , xlRows, xlPrevious).Offset(1).Select


--
Rick (MVP - Excel)



"Mike H" wrote in message
...
Hi,

It is very unlikely that you will need to select a cell to do what you
want
but here's a couple of methods

Select empty cell after last used cell in col A
Range("A" & Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1).Select

Select empty cell in Col A below the last use cell on worksheet
Range("A" & Cells.SpecialCells(xlLastCell).Row + 1).Select
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Copacetic" wrote:

Hello,

I have some code that adds the contents of one sheet to the end of
another. How do I correctly select the first empty cell below the first
sheet that I want to add data to?

Something like

ActiveCell.SpecialCells(xlLastCell).Select

'Move to bottom of range

^^^ This is where I need work.

Can I simply perform a cursor key move down one cell?

How do I code cursor key operations?
.