Thisworkbook.Names get: Name Value ReferTo Scope Comment...

drom

Well-known Member
Joined
Mar 20, 2005
Messages
543
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Hi and thanks in advance

When I go in a Excel Workbook to:
  • Formulas/Name Manager I can See there the different names:
    • Name
    • Value
    • Refers To
    • Scope
    • Comment
How Can i get for the diferent names in a Workbook
  • Name Value ReferTo Scope Comment ???
VBA Code:
Dim nm As Name
For Each nm In Thisworkbook.Names
    Debug.Print nm.Name ??
    Debug.Print nm.Value  ??
    Debug.Print nm.RefersToRange.Parent.Name  ??
    Debug.Print nm.Scope ??
    Debug.Print nm.Comment ??
    Debug.Print nm.Visible
    Debug.Print nM.??.
Next nm

I mean how can I get the mainly:
  • Name Value ReferTo Scope Comment
  • And If I can get something else Better
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Does this meet your needs?
VBA Code:
Sub NamedRangeInfo()
    Dim nm As Name
    For Each nm In ThisWorkbook.Names
        Debug.Print "Name = " & nm.Name
        Debug.Print "Value = " & nm.Value
        Debug.Print "Parent = " & nm.RefersToRange.Parent.Name
        Debug.Print "Scope = " & NamedRangeScope(nm)
        Debug.Print "Comment = " & NamedRangeComment(nm)
        Debug.Print "Visible = " & IIf(nm.Visible, "True", "False")
        Debug.Print "=================================="
    Next nm
End Sub

' Return the comment of a named range.
Function NamedRangeComment(namToCheck As Name) As String
    NamedRangeComment = vbNullString
    On Error Resume Next
    NamedRangeComment = namToCheck.RefersToRange.Comment.Text
End Function

' Return the scope of a named range.
Function NamedRangeScope(namToCheck As Name) As String
    Dim lngPosn As Long
    lngPosn = InStr(namToCheck.Name, "!")
    If (lngPosn > 0) Then
        NamedRangeScope = Left(namToCheck.Name, lngPosn - 1)
    Else
        NamedRangeScope = "Workbook"
    End If
End Function
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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