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.
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.
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
<gimme_this_gimme_that@yahoo.com> wrote in message
news:1141919392.667152.185990@u72g2000cwu.googlegroups.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.
>
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
"gimme_this_gimme_that@yahoo.com" 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.
>
>
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
>
>
> <gimme_this_gimme_that@yahoo.com> wrote in message
> news:1141919392.667152.185990@u72g2000cwu.googlegroups.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.
> >
Dim LastRowNumber as long
lastrownumber = lastrow.row
gimme_this_gimme_that@yahoo.com 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
> >
> >
> > <gimme_this_gimme_that@yahoo.com> wrote in message
> > news:1141919392.667152.185990@u72g2000cwu.googlegroups.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
> 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
<gimme_this_gimme_that@yahoo.com> wrote in message
news:1141926856.084019.94560@e56g2000cwe.googlegroups.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
>>
>>
>> <gimme_this_gimme_that@yahoo.com> wrote in message
>> news:1141919392.667152.185990@u72g2000cwu.googlegroups.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.
>> >
>
Oh ... Sweet.
Thanks guys.
Dim val as Integer
val = sheet.Cells(rows.Count, "A").End(xlUp).Row
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks