Identifying named range from ActiveCell within the range

fpperryaz

New Member
Joined
Sep 27, 2005
Messages
9
Can someone tell me the syntax to use to get the Named Range address, from the Active Cell. I have selected a cell within a named range and need to identify the range for a macro. Thanks for any help.

Frank
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I don't quite understand. You want the address of the named range, or the address of the active cell?

For the active cell, you could use:
Code:
ActiveCell.Address

For a named range, use:
Code:
Range("myRange").Address

where myRange is the name of the range.

HTH
 
Upvote 0
If you want to get the name and address of the named range that contains the selected cell :-

Code:
Sub Get_NamedRange_Address()
Dim n As Variant, rng As Range
If Selection.Cells.Count <> 1 Then Exit Sub
On Error GoTo e
For Each n In Application.Names
    Set rng = Range(Mid(n, 2))
    If Not rng Is Nothing Then
        If Not Intersect(rng, Selection) Is Nothing Then
            MsgBox "The selected cell is in " & n.Name & " (" & rng.Address(0, 0) & ")"
            Exit Sub
        End If
    End If
e:
Next n
MsgBox "There is no named range that contains the selected cell"
End Sub
 
Upvote 0
This will goto each Named Range one at a time!

Sub allRangeNm()
For Each nm In ThisWorkbook.Names
If nm.Name <> "" Then
Range(nm).Select
MsgBox "Found one At: " & nm & vbLf & vbLf & "Named: " & nm.Name
End If
Next nm
End Sub
 
Upvote 0
re: Identify named range of Active cell

TazGuy: I know the address of the ActiveCell. I want the name of the range that contains it so that I can select the whole range for use. Thanks.

Mr Jones & Joe: I will test your code in the morning and report back. Thanks

Frank
 
Upvote 0

Forum statistics

Threads
1,202,984
Messages
6,052,913
Members
444,612
Latest member
FajnaAli

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