Results 1 to 5 of 5
  • Thread Tools
  1. 5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'd like to test is a cell has a name and if so, find out what that name is. The name to reflect the cell only (so not refer to more cells).

    An example is probably a good thing... Some cells have a special purpose in my sheet; I am giving these (individual cells) a name, e.g. cell G3, when identified for the special purpose will have the name "Special_G3".

    Now if the user is doing something with a cell, I need to test in VBA is that cell is special, so I'd like to find out if that cell has a name and if that name is "Special_G3" in this case (also, and obviously, "Special_G3" should only apply to ONE cell (G3))

    I'm not sure how difficult this is, Range("G3").Name doesn't do the trick (that would have been too simple I guess )

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 13 Times in 13 Posts
    If G3 has a name, you can use Range("G3").Name.Name to retrieve it.
    If G3 does not have a name, that would cause an error, so you'd have to use an error handler to suppress error messages.


  4. 5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    If G3 has a name, you can use Range("G3").Name.Name to retrieve it.
    If G3 does not have a name, that would cause an error, so you'd have to use an error handler to suppress error messages.
    OK, getting there... all that's left is giving the cell a name, I thought this would work (and sometimes it does, but most of the times I get an error):

    ActiveWorkbook.Names.Add Name:="Tag_" & ActiveCell.Address(False, False), RefersTo:=ActiveCell.Name

    In words: If the activecell is G10, I want to create a range name for cell G10 and name that "Tag_G10"

  5. Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Change it to

    ActiveWorkbook.Names.Add Name:="Tag_" & ActiveCell.Address(False, False), RefersTo:=ActiveCell

  6. 5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    Change it to

    ActiveWorkbook.Names.Add Name:="Tag_" & ActiveCell.Address(False, False), RefersTo:=ActiveCell
    Oops...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •