is there a way to get the definition of a defined name into an excel cell?

TomCon

Active Member
Joined
Mar 31, 2011
Messages
373
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I want to get the definition of a defined Name into an excel cell.

So, if i have a name, MyName, and it is defined as Sheet1!A1:A10, i want to get the text string "Sheet1!A1:A10" into an Excel cell.

=MyName does not do it.
Also =T(MyName) does not do it.

Is there a way?

Thanks!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
How about
Excel Formula:
=CELL("address",MyName)
 
Upvote 0
How about
Excel Formula:
=CELL("address",MyName)
It turns out that this returns the address of the first cell, but not the text of the definition. So, if MyName is "Sheet1:A1:A10" you will get [workbook]Sheet1!A1. But, thanks for the response.

If anybody has thoughts on how to get the whole Defined Name definition into a cell, please post!

Thanks!
 
Upvote 0
Why do you need to get the refers to address in a cell?
 
Upvote 0
Use a user-defined function?

VBA Code:
Function Refers_To(strName As String) As String
  Dim nm As Name
  
  For Each nm In ThisWorkbook.Names
    If UCase(nm.Name) = UCase(strName) Then
      Refers_To = Mid(Replace(nm.RefersTo, "$", ""), 2)
      Exit For
    End If
  Next nm
End Function

TomCon.xlsm
A
1Sheet1!A1:A10
Sheet2
Cell Formulas
RangeFormula
A1A1=Refers_To("MyName")
 
Upvote 0
A bit longer, but it works:
Code:
=MID(CELL("filename",myName),SEARCH("]",CELL("filename",myName))+1,255)&"!"&CELL("address",myName) & ":" &
 ADDRESS(AGGREGATE(14,6,ROW(myName),1),AGGREGATE(14,6,COLUMN(myName),1))
 
Upvote 0
add an empty sheet or select a range that is big enough for all the used names.
then in the ribbon Formulas>use in formula>Paste names>Paste Liste (hope it's the right translation)


Schermafbeelding 2022-07-26 092739.jpg
 
Upvote 0
Solution
i want to get the text string "Sheet1!A1:A10" into an Excel cell

add an empty sheet or select a range that is big enough for all the used names.
then in the ribbon Formulas>use in formula>Paste names>Paste Liste (hope it's the right translation)

As I read it, that doesn't quite produce the result as asked for - and may produce a long list of results.

A bit longer, but it works:
Code:
=MID(CELL("filename",myName),SEARCH("]",CELL("filename",myName))+1,255)&"!"&CELL("address",myName) & ":" &
 ADDRESS(AGGREGATE(14,6,ROW(myName),1),AGGREGATE(14,6,COLUMN(myName),1))
Well, I don't think it quite works as requested (at least it didn't for me) as shown in D1 below, but using your idea the modified/shortened version in D2 seems to.

Cell Formulas
RangeFormula
D1D1=MID(CELL("filename",MyName),SEARCH("]",CELL("filename",MyName))+1,255)&"!"&CELL("address",MyName) & ":" & ADDRESS(AGGREGATE(14,6,ROW(MyName),1),AGGREGATE(14,6,COLUMN(MyName),1))
D2D2=LET(s,CELL("address",MyName) & ":" &ADDRESS(AGGREGATE(14,6,ROW(MyName),1),AGGREGATE(14,6,COLUMN(MyName),1)),SUBSTITUTE(REPLACE(s,1,FIND("]",s),""),"$",""))
 
Upvote 0
add an empty sheet or select a range that is big enough for all the used names.
then in the ribbon Formulas>use in formula>Paste names>Paste Liste (hope it's the right translation)


View attachment 70106
yes, this works. What an obscure hidden place, but thanks! Gives just the list i need.
 
Upvote 0
As I read it, that doesn't quite produce the result as asked for - and may produce a long list of results.


Well, I don't think it quite works as requested (at least it didn't for me) as shown in D1 below, but using your idea the modified/shortened version in D2 seems to.

Cell Formulas
RangeFormula
D1D1=MID(CELL("filename",MyName),SEARCH("]",CELL("filename",MyName))+1,255)&"!"&CELL("address",MyName) & ":" & ADDRESS(AGGREGATE(14,6,ROW(MyName),1),AGGREGATE(14,6,COLUMN(MyName),1))
D2D2=LET(s,CELL("address",MyName) & ":" &ADDRESS(AGGREGATE(14,6,ROW(MyName),1),AGGREGATE(14,6,COLUMN(MyName),1)),SUBSTITUTE(REPLACE(s,1,FIND("]",s),""),"$",""))
Yes, this does work to get a single name but the paste list below gets them all which is what i need. Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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