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
20
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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,216,101
Messages
6,128,843
Members
449,471
Latest member
lachbee

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