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

This is an interesting one! The name property of a range
(or cell) is not the string it is named, but another name
object, so ActiveCell.Name.Name returns "Hello". However,
if the cell is not named at all, you will just get an
error. Not sure how you tell if a cell has a name attached
or not.

As long as you know the "Hello" cell exists the best way
is just to check if it is the ActiveCell - that is:

If ws.Range("Hello").Address = ActiveCell.Address Then
MsgBox ("YES")
......
.....

Regards, Andy


-----Original 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


.