ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   finding last row number of UsedRange (https://www.excelbanter.com/excel-programming/278047-finding-last-row-number-usedrange.html)

Jamie Martin[_2_]

finding last row number of UsedRange
 
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



shockley

finding last row number of UsedRange
 
x = Cells.SpecialCells(xlCellTypeLastCell).Row
y = Cells.SpecialCells(xlCellTypeLastCell).Column

HTH,
Shockley

"Jamie Martin" wrote in message
...
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





Bill Barclift

finding last row number of UsedRange
 
Last column number in range:
MyRange.Columns(MyRange.Columns.Count).Column

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

Bill Barclift



"Jamie Martin" wrote in message
...
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





J.E. McGimpsey

finding last row number of UsedRange
 
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

In article ,
"Jamie Martin" wrote:

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



Jamie Martin[_2_]

finding last row number of UsedRange
 
Thanks. It sounds like Perl should not be the only language whose motto is
"There's more than one way to do it."

"J.E. McGimpsey" wrote in message
...
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

In article ,
"Jamie Martin" wrote:

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






All times are GMT +1. The time now is 04:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com