Reputation: 2861
Having an issue finding information and/or solutions that produce the desired result, so here it goes.
Right now, and potentially at production time, i will have a "template" named-range on a worksheet. On first use this NamedRange is only rngNamed1
but after the first use there could be more Named Ranges similar to this one, say up to rngNamed30
.
Lets say on the 2nd run after building up to rngNamed30
, that i need to add 3 more of the NamedRange, which results in rngNamed33
.
What i need to do is basically find the last row & column of the last Named Range, so i know where to start the copying of data to and declare the next Named Range.
Dim rng As range
Set rng = range("rngNamed1")
'Set rng = rng.Find("*", rng.Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False)
Debug.Print rng.Find("*", rng.Cells(1, 1), , , , xlPrevious).Address
The problem with most of the solutions out there is they are based on finding the last cell WITH DATA. I just need to know the Last Cell of the Range, irregardless of whether it contains data or not.
Upvotes: 3
Views: 24622
Reputation: 2693
You can do this easily using the Row and Rows.Count of the range:
Sub NextRowAfterRange()
Dim ws As Worksheet
Dim rangeNom As String
Dim nextRow As Long
' Enter desired name here
rangeNom = "rngName1"
Set ws = ActiveSheet
nextRow = ws.Range(rangeNom).Row + ws.Range(rangeNom).Rows.Count
MsgBox nextRow
End Sub
Upvotes: 8