Use code like
Dim LastCell As Range
Dim WS As Worksheet
Set WS = ActiveSheet
Set LastCell = WS.UsedRange.SpecialCells(xlCellTypeLastCell)
Debug.Print LastCell.Address
Note, though, that this LastCell may not contain any data. It is in
the last row that has any data in it and in the last column that has
any data in it. E.g.,
X X
X X
X LC
Where X is data and LC is the LastCell, which may be empty.
If you need the last cell that has data, you need to decide whether
you want the right-most column or the highest-number row. For example,
X X X
X X 11
X
22
In this example, is 11 or 22 the last cell? It depends on what you are
looking for and what you need to accomplish with the last cell.
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)