• Find last row of named range using VBA (Excel 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Find last row of named range using VBA (Excel 2000)

    Author
    Topic
    #427759

    Is there a way to determine via code what is the last row included in a named range, regardless of whether there is data in the last row or not? For example, if I have a sheet with a named range “Section1” that is defined as A1:C10, how can I determine that the last row is row 10? Even better, that the bottom left corner is cell A10? Perhaps I’m missing something obvious, but I’m not finding an easy way to do this.

    Thanks!

    Viewing 1 reply thread
    Author
    Replies
    • #991975

      Sure:


      Dim lRow As Long
      lRow = Range("MyRange").Cells(1, 1).Row + Range("MyRange").Rows.Count - 1

    • #991976

      The following expression returns a reference to the bottom left corner of Section1 (assuming it consists of a single contiguous area):

      Range(“Section1”).Cells(Range(“Section1”).Rows.Count,1)

      To retrieve the address of this cell:

      Range(“Section1”).Cells(Range(“Section1”).Rows.Count,1).Address

      • #991979

        Beautiful, that’s just what I need. Hans and Legare, thanks to you both.

    Viewing 1 reply thread
    Reply To: Find last row of named range using VBA (Excel 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: