ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Last used row (https://www.excelbanter.com/excel-programming/355575-last-used-row.html)

[email protected]

Last used row
 
I need to loop through all the rows on a worksheet ...

There are patches where there are groups of existing but unused rows
....

How do I get the last used row in VBA?

Thanks.


Chip Pearson

Last used row
 
Try something like the following. Change the "A" to the
appropriate column.

Dim LastRow As Range
Set LastRow = Cells(Rows.Count, "A").End(xlUp)



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
oups.com...
I need to loop through all the rows on a worksheet ...

There are patches where there are groups of existing but unused
rows
...

How do I get the last used row in VBA?

Thanks.




Gary''s Student

Last used row
 
Try:

Sub Find_lur()
Dim j, i, k As Long
' gsnu find last used row
k = 0
j = 65536
For i = j To 1 Step -1
If Application.CountA(Rows(i)) = 0 Then
Else
k = i
Exit For
End If
Next i
MsgBox (k)
End Sub
--
Gary''s Student


" wrote:

I need to loop through all the rows on a worksheet ...

There are patches where there are groups of existing but unused rows
....

How do I get the last used row in VBA?

Thanks.



[email protected]

Last used row
 
Thanks Chip.

Where almost there...

How do I get the integer value of the last row from the Range LastRow ?

Dim LastRow As Range
Set LastRow = Cells(Rows.Count, "A").End(xlUp)



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
oups.com...
I need to loop through all the rows on a worksheet ...

There are patches where there are groups of existing but unused
rows
...

How do I get the last used row in VBA?

Thanks.



Dave Peterson

Last used row
 
Dim LastRowNumber as long
lastrownumber = lastrow.row





wrote:

Thanks Chip.

Where almost there...

How do I get the integer value of the last row from the Range LastRow ?

Dim LastRow As Range
Set LastRow = Cells(Rows.Count, "A").End(xlUp)



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
oups.com...
I need to loop through all the rows on a worksheet ...

There are patches where there are groups of existing but unused
rows
...

How do I get the last used row in VBA?

Thanks.


--

Dave Peterson

Chip Pearson

Last used row
 
How do I get the integer value of the last row from the Range
LastRow ?


LastRow.Row


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
ups.com...
Thanks Chip.

Where almost there...

How do I get the integer value of the last row from the Range
LastRow ?

Dim LastRow As Range
Set LastRow = Cells(Rows.Count, "A").End(xlUp)



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
oups.com...
I need to loop through all the rows on a worksheet ...

There are patches where there are groups of existing but
unused
rows
...

How do I get the last used row in VBA?

Thanks.





[email protected]

Last used row
 
Oh ... Sweet.

Thanks guys.

Dim val as Integer
val = sheet.Cells(rows.Count, "A").End(xlUp).Row



All times are GMT +1. The time now is 09:00 AM.

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