View Single Post
 
Old 01-25-2022, 12:01 PM
NoSparks NoSparks is offline Windows 10 Office 2010
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Here's a macro that will build that formula and add the named range
Code:
 Sub Create_Dynamic_Range()

    Dim RngName As String, ShtName As String, StartAddress As String
    Dim RngCol As String, ReferString As String
    
    RngName = ActiveCell.Value
    ShtName = ActiveCell.Parent.Name & "!"
    RngCol = "$" & Split(Mid(ActiveCell.Address, 2), "$")(0)
    StartAddress = ActiveCell.Offset(1).Address
    ReferString = "=" & ShtName & StartAddress & ":INDEX(" & ShtName & RngCol & ":" & _
                      RngCol & ",COUNTA(" & ShtName & RngCol & ":" & RngCol & "))"
    ActiveWorkbook.Names.Add Name:=RngName, RefersTo:=ReferString

End Sub
Attached Files
File Type: xlsm Named_Ranges.xlsm (16.2 KB, 5 views)
Reply With Quote