+ Reply to Thread
Results 1 to 4 of 4

Check if a named range refers to a constant or a range

  1. #1
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019, Microsoft 365.
    Posts
    440

    Check if a named range refers to a constant or a range

    Hi everyone,

    I have a macro below to modify named range to right sizes. But the macro will fail if there are some names which refer to constant or formula, instead of a range. I think nm.RefersToRange.Name will fail if nm does not refer to a range.

    My question is: is there a way to test if a name refers to a constant? If so, please don't do anything about that name. For other names that refer to a range, then action is taken to process them.

    Please Login or Register  to view this content.
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Check if a named range refers to a constant or a range

    Don't know if it's fool proof but how about testing for '!' in RefersTo?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: Check if a named range refers to a constant or a range

    Try this!

    Please Login or Register  to view this content.
    Last edited by JEC.; 02-01-2024 at 02:02 PM.

  4. #4
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019, Microsoft 365.
    Posts
    440

    Re: Check if a named range refers to a constant or a range

    Thanks to Norie and JEC. I am happy to close the thread now - your solutions work nicely!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Named Range Suddendly Refers to a Different Sheet
    By FallingDown in forum Excel General
    Replies: 3
    Last Post: 04-06-2020, 10:59 AM
  2. [SOLVED] Changing refers to for specific named range
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-14-2019, 10:33 AM
  3. Creating a named range which refers to a dynamic range with VBA
    By Pete000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-04-2019, 06:02 PM
  4. Replies: 12
    Last Post: 07-08-2011, 10:48 AM
  5. creating named range in workbook that refers to VBA range
    By twd000 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2008, 05:42 PM
  6. Named Range Refers To
    By Tim in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2006, 11:00 PM
  7. toggling which worksheet a named range refers to
    By Loftus in forum Excel General
    Replies: 0
    Last Post: 03-29-2005, 08:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1