Is there a function that will return the name of a range?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,646
Office Version
  1. 365
Platform
  1. Windows
Say B5 has been assigned the name "SalesDate". Is there a function (=getname(B5)) that will return the name ("SalesDate")?
 
This worked for me :
VBA Code:
Function GetRangeName(ByVal Rng As Range, Optional ByVal FullName As Boolean = False) As String

    Dim sName As String
    On Error Resume Next
   
    sName = Rng.Name.Name
    GetRangeName = IIf(FullName, sName, Right(sName, Len(sName) - InStrRev(sName, "!")))

End Function

This works if the Rng has a name, but it gets a Value error if not.

GetRangeName.xlsx
CDE
5NameCell AddressRange Name
6Name is: AAA
7Name is: NextNameNextNameNextName
8Name is: #VALUE!#VALUE!
Sheet1
Cell Formulas
RangeFormula
D6:D8D6=GetRangeName(C6)
E6E6=GetRangeName(A)
E7E7=GetRangeName(NextName)
E8E8=GetRangeName(C8)
Named Ranges
NameRefers ToCells
A=Sheet1!$C$6D6:E6
NextName=Sheet1!$C$7D7:E7
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,221,525
Messages
6,160,327
Members
451,637
Latest member
hvp2262

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