How to List All Name Ranges in Excel Add-in? with code example

How to List All Name Ranges in Excel Add-in? with code example

ListNames

Excel Range object offers ListNames method which can be used to populate all visible name ranges of a workbook in a range. ListNames method returns two dimension result having Range Name and RefersTo as shown below in example.

Syntax

RangeObject.ListNames

Data source

Available names

Code example

Public Sub ListNamesExample()
    'Range object
    Dim oRange As Range
    
    'Bind selection
    Set oRange = Selection
    
    'Populate List names
    oRange.ListNames
    
    'Cleanup
    If Not oRange Is Nothing Then
        Set oRange = Nothing
    End If
End Sub

Output

Next >> Dynamic Range Creation Excel Add-in

Leave a Reply

Your email address will not be published.