Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi guys

Please let me know if there is any shortcut to know the named range of a excel cell by just
placing the cursor over the cell.
Posted
Updated 15-May-13 5:10am
v2
Comments
Sergey Alexandrovich Kryukov 15-May-13 10:57am    
Not a question.
—SA
Maciej Los 15-May-13 13:18pm    
What kind of shortcut? Please, provide more details...
Sagar Devanahalli 16-May-13 2:14am    
Any key combinations when pressed after selecting a cell should show its name range[defined name of the cell].

1 solution

Steps to do:
1) Go to the code pane: ALT+F11
2) Add new module
3) Copy and paste below code:
VB
Option Explicit

Sub test()
MsgBox GetNamedRange(Workbooks("YourWorkbookName.xls").Worksheets("YourWorksheetName").Range("A2"))
MsgBox GetNamedRange(ActiveCell)
End Sub

'returns the name of NamedRange
Function GetNamedRange(rng As Range) As String
Dim r As Range, n As Name
Dim wsh As Worksheet, wbk As Workbook
Dim sRetVal As String

On Error Resume Next

Set wsh = rng.Parent
Set wbk = wsh.Parent

'go through the collection of names, including the all worksheet-specific names
For Each n In wbk.Names
    r = n.RefersTo
    If r.Address = rng.CurrentRegion.Address Then
        sRetVal = n.NameLocal
        Exit For
    End If
Next

GetNamedRange = sRetVal

End Function

4) Test it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900