using a defined name in a macro


Posted by Elizabeth on August 17, 2000 6:16 PM

Hello,
In a macro I'm trying to compare the value of a cell to the value of a another cell which I have named. However, the macro is not recognizing the named cell as having a value. Please note that the content of the named cell is text and the named cell is located in a different worksheet in the same file. Is there something I'm missing?

I've tried:
If ActiveCell.Value = Range(name1).Value Then True ...
and
If ActiveCell.Value = name1 Then True ...
and neither works.

I should say that when I use the same formula within a cell instead of in a macro [=if(a1=name1,true,false)] then everything works just fine.

Can anyone help clear this up?

THANKS!!!

Posted by Elizabeth on August 18, 0100 11:49 AM

Thanks for the suggestion. I tried that and it still does not recognize the value. Anything else I could try?

Posted by elizabeth on August 18, 0100 12:19 PM

Kept fiddling and got it to work,

Thanks for your help!!!! Thanks for the suggestion. I tried that and it still does not recognize the value. Anything else I could try?



Posted by Michael Liu on August 17, 0100 7:40 PM

try putting the named reference in quotes.
range("name1").value
otherwise, excel will think name1 is a VB
variable.