Last Row In Named Range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone tell me how to return the last row in a named range?

Thank you.
Sprinks
 
Try this
lastRow = Cells(Rows.Count, NamedRange.Columns(1)).End(xlUp).Row
 
sorry, you wanted the row, not the cell
i = Range("test").SpecialCells(xlCellTypeLastCell).Row
 
Can someone tell me how to return the last row in a named range?

LastRow = Range("YourRangeName").Row + Range("YourRangeName").Count - 1

or, more compactly....

With Range("MyRange")
LastRow = .Row + .Count - 1
End With


Rick
 
One more (useful if there are multiple areas in the range):

Option Explicit
Sub testme()

Dim myRng As Range
Set myRng = Worksheets("Sheet1").Range("myname")

With myRng
With .Areas(.Areas.Count)
MsgBox .Rows(.Rows.Count).Row
End With
End With

End Sub
 
Just to add, if not certain the 'last' area contains the 'lowest' row, would
need to loop each area.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top