View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rich[_7_] Rich[_7_] is offline
external usenet poster
 
Posts: 6
Default Returning the range name in VBA

In this situation I would use

If Activecell.Range.Name.Name="Revenue" then DoSomething

(note the name.name to return the name of the cell as you have defined it)

however, just today it started returning the name of the sheet and then the
cell and I can't work out why. I have a feeling it has something to do with
the exporting sheets and stuff like that.

Cheers!



"John Tjia" wrote:


I have a macro that I would like to run based on whether the cursor is
on a particular cell, or more specifically, if it is on a particular
range name. I've tried something like:

If Activecell.Range.Name="Revenue" then DoSomething

and other variations, but no luck. I can't seem to find the way to
return the range name. BTW, Revenue is a one-cell range.

If Activecell.Address="$C$3"="Revenue" then DoSomething


works, but I would like to be able to use the range name to facilitate
worksheet changes later.

Thanks for any help!


--
John Tjia
------------------------------------------------------------------------
John Tjia's Profile: http://www.excelforum.com/member.php...fo&userid=4681
View this thread: http://www.excelforum.com/showthread...hreadid=268487