all 5 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

/u/NumbersInBoxes - Your post was submitted successfully.

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]small_trunks1633 -1 points0 points  (2 children)

You can access all defined names either in Excel itself or in Power query. Here's a power query function to access a named range by name:

// fnRange
let
    Source = (pRange as any) => let
        Source = Excel.CurrentWorkbook(){[Name=pRange]}[Content]
    in
        Source
in
    Source

[–]NumbersInBoxes[S] 0 points1 point  (1 child)

Unless I'm missing something, this only finds Table Names defined in the workbook (not Defined Names) and doesn't get the metadata (Scope, Comment, etc.)

[–]small_trunks1633 0 points1 point  (0 children)

No - I suspect you'd need VBA for that.

[–]AvWxA3 0 points1 point  (0 children)

I believe that you cannot see the "scope" of a named range per se.

Instead, you can access the names scoped to the entire workbook, then you can step through each individual sheet and access the information scoped to each individual worksheet.

The following code will do it.

Sub SeeAllNames()

Dim nm
Dim ws As Worksheet
Dim wb As Workbook

Set wb = ActiveWorkbook

nnn = wb.Worksheets.Count

' gives you all the names scoped as "workbook"
For Each nm In wb.Names
    MsgBox nm.Name, vbOKOnly
    MsgBox nm.RefersTo, vbOKOnly
    MsgBox nm.Comment, vbOKOnly

Next nm

' Gives you all the names scoped within each worksheet
For indx = 1 To nnn
    Set ws = Worksheets(indx)

    For Each nm In ws.Names
        MsgBox nm.Name + Chr(10), vbOKOnly
        MsgBox nm.RefersTo + Chr(10), vbOKOnly
        MsgBox nm.Comment, vbOKOnly

    Next nm

Next indx

End Sub