Range Name

  • Thread starter Thread starter ranswert
  • Start date Start date
R

ranswert

I used the following code to get the name of a cell:

dim a as string
a = ActiveCell.name.name

Can I do something similiar to get the name of a range of cells?
Thanks
 
Are you trying to get a Name or address?

This code get an address
a = Selection.Address

Use intersect to check if cell is the range of a named item

Sub test()

For Each nm In ThisWorkbook.Names
nmRange = Mid(nm, 2)
Set isect = Application.Intersect(Range(nm), ActiveCell)
If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
MsgBox "Ranges ntersect"
End If

Next nm

End Sub
 
Dim A as string
a = ""
on error resume next
a = activesheet.range("a1:x99").name.name
on error goto 0

if a = "" then
msgbox "no name for that range"
else
msgbox a
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top