View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Determining the last row and column used on a sheet


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)


On Mon, 23 Feb 2009 09:19:02 -0800, John
wrote:

How can I quickly find the last used row and column of a worksheet?

I appreciate your help, -John