Thread: Range Name
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Range Name

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


"ranswert" wrote:

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