Set last = LastCell(Sheet2)
Cells(last.Row,"A").Select
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"andibevan " wrote in message
...
Hi there,
I am using the following code that I have been told is fairly
infallable at finding the last populated row of my data table. The
routine Last_Row then displays the last row number. What I can't
manage to figure out how to do is actually select column A of the Last
row - sure it is simple but I am missing it.
Thanks
Andi
Function LastCell(ws As Worksheet) As Range
Dim LastRow&, LastCol%
' Error-handling is here in case there is not any
' data in the worksheet
On Error Resume Next
With ws
' Find the last real row
LastRow& = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
' Find the last real column
LastCol% = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
End With
' Finally, initialize a Range object variable for
' the last populated row.
Set LastCell = ws.Cells(LastRow&, LastCol%)
End Function
----------------------------------------------
Sub Show_Last_Row()
MsgBox LastCell(Sheet2).Cell
End Sub
---
Message posted from http://www.ExcelForum.com/