+ Reply to Thread
Results 1 to 7 of 7

Last used row

  1. #1

    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. #2
    Chip Pearson
    Guest

    Re: 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


    <[email protected]> wrote in message
    news:[email protected]...
    >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. #3
    Gary''s Student
    Guest

    RE: 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


    "[email protected]" 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. #4

    Re: 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
    >
    >
    > <[email protected]> wrote in message
    > news:[email protected]...
    > >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. #5
    Dave Peterson
    Guest

    Re: Last used row

    Dim LastRowNumber as long
    lastrownumber = lastrow.row





    [email protected] 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
    > >
    > >
    > > <[email protected]> wrote in message
    > > news:[email protected]...
    > > >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. #6
    Chip Pearson
    Guest

    Re: 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


    <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >>
    >>
    >> <[email protected]> wrote in message
    >> news:[email protected]...
    >> >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. #7

    Re: Last used row

    Oh ... Sweet.

    Thanks guys.

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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1