Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default 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.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Last used row

Oh ... Sweet.

Thanks guys.

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"