finding last row number of UsedRange

  • Thread starter Thread starter Jamie Martin
  • Start date Start date
J

Jamie Martin

I want to loop through all the rows in my active worksheet's UsedRange. How
can I extract from the UsedRange Range object the numbers of the last row
and column?

Thanks everyone so much for your help--I really appreciate this community.

Jamie
 
x = Cells.SpecialCells(xlCellTypeLastCell).Row
y = Cells.SpecialCells(xlCellTypeLastCell).Column

HTH,
Shockley
 
Last column number in range:
MyRange.Columns(MyRange.Columns.Count).Column

Last row number in range
MyRange.Rows(MyRange.Rows.Count).Row

Bill Barclift
 
You don't really need the numbers...

Dim myRow As Range
Dim myCell As Range
With ActiveSheet.UsedRange
For Each myRow In .Rows
For Each myCell In Intersect(.Cells, myRow)
'Do something to the cell
Next myCell
Next myRow
End With

One way to get the last row and column:

Dim lastRow As Long
Dim lastCol As Integer
With ActiveSheet.UsedRange
lastRow = .Cells(.Count).Row
lastCol = .Cells(.Count).Column
End With
 
Thanks. It sounds like Perl should not be the only language whose motto is
"There's more than one way to do it."
 
Back
Top