View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
John Wilson John Wilson is offline
external usenet poster
 
Posts: 550
Default If Range.Name question

Otto,

Remember Google ??? <vbg

From a John Greene post.....

for a single cell range:
Activecell.Name.Name

for a multiple cell range:
Sub WhereAmI()
Dim n As Name
On Error Resume Next
For Each n In Names
If Intersect(ActiveCell, n.RefersToRange) Is Nothing Then
Else
MsgBox "Active cell is in " & n.Name
Exit Sub
End If
Next n
End Sub

John


"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I want to check if the ActiveCell range name is "Hello". I thought this
little macro would work but it returns a "No". What is the correct way to
make this check? Thanks for your help. Otto
Sub TestName()
If ActiveCell.Name = "Hello" Then
MsgBox "Yes"
Else
MsgBox "No"
End If
End Sub