Is there an excel function that will return the name of the named range in cell A1

PeterMac65

New Member
Joined
May 7, 2020
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hi,

If I gave cell A1 the range-name "Apple", is there a function that will return "Apple"?



eg =example(A1) returns "Apple



I would prefer not to use VBA, but will if there is no other option.



Regards Peter
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Like this:

VBA Code:
Function GetNamedRange(cell As Range) As String
    Dim nm As Name
    For Each nm In ThisWorkbook.Names
        If Not Intersect(cell, Range(nm.RefersTo)) Is Nothing Then
            GetNamedRange = nm.Name
            Exit Function
        End If
    Next nm
    GetNamedRange = ""
End Function
 
Upvote 0
You can get the entire list by Formula Tab -> Use in Range -> Paste Name->Paste List.
 
Upvote 0
Like this:

VBA Code:
Function GetNamedRange(cell As Range) As String
    Dim nm As Name
    For Each nm In ThisWorkbook.Names
        If Not Intersect(cell, Range(nm.RefersTo)) Is Nothing Then
            GetNamedRange = nm.Name
            Exit Function
        End If
    Next nm
    GetNamedRange = ""
End Function
Thanks Bebo,
I have several hundred rangenames and will be calling this function many times. Is there a way to restrict the number of names to loop through? Perhaps just the cell passed into the function?

Or Is there a non VBA alternative?

If not I might just have to type the named ranges into about 50 formulas.
 
Upvote 0
How about
VBA Code:
Function GetName(Rng As Range) As String
   GetName = Rng.Name.Name
End Function
If the named range is more than a single cell, you need to pass the entire range.
 
Upvote 0
Solution
Function GetName(Rng As Range) As String GetName = Rng.Name.Name End Function
Thanks Fluff. That is perfect.
I use it as follows"
=XLOOKUP(getname(iInsulationToSlab),specRangeName,specFormula,"Not found")
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top