Selecting the first cell of the last row in a range

  • Thread starter Thread starter Susan Ramlet
  • Start date Start date
S

Susan Ramlet

A co-worker asked me how to programmatically select the first cell of the
last row in a range in Excel 2003 (Windows XP). We found the Help reference
to selecting the last cell in a range, but we couldn't come up with a good
solution for the first cell in the last row, other than a "SendKeys" type of
solution to send "Ctl-down arrow", which is a bit too imprecise.

Neither of us is a strong coder, but he's trying to use a macro to get
there.

Any ideas would be welcome!
 
This will find the last row on the active sheet and then select col A in
that row.

Sub firstcelloflastrow()
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _
, , , xlByRows, xlPrevious).Row
'MsgBox lr
Cells(lr, 1).Select
'or
'Cells(lr, 1).End(xlToRight).Select
'to goto the first non blank cell on THAT row

End Sub
 
Thank you, Don! We will put this to use. I appreciate the quick and complete
response.
 
He wants to select the first cell of the last row of a range and then format
it programmatically (I don't know the specific objective in the context of
the overall spreadsheet; sorry...).
 
Selecting is NOT necessary
Sub firstcelloflastrow()
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _
, , , xlByRows, xlPrevious).Row
'MsgBox lr

Cells(lr, 1).numberformat=???
or
format(Cells(lr, 1), "mm/dd")
'or
'Cells(lr, 1).End(xlToRight).Select
'to goto the first non blank cell on THAT row

End Sub
 
Back
Top