+ Reply to Thread
Results 1 to 4 of 4

Using code to delete a named range

  1. #1
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Using code to delete a named range

    I have a worksheet that is locked so there does not seem to be a way to permit a user to delete a named range but was hoping that I might be able to get around that restriction by using some code.

    I found the following code that works however I'd like to be able to pass a name to the code from what a user enters into a cell. Is there a way to replace the xxx value with a cell reference so a user can type in the name of the range they want to remove from Name Manager into a specific cell?

    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,234

    Re: Using code to delete a named range

    The way to do exactly what you ask is this. Replace red values with your actual values.

    Please Login or Register  to view this content.
    However, what I would do is prompt the user, instead of putting it in a cell:
    Please Login or Register  to view this content.
    I have compiled but not tested these.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Re: Using code to delete a named range

    The option to prompt for the name works great and is a cleaner way to perform it, thank you for both suggestions. I did find however that access to the Name Manager opens up if the user can open a new worksheet or switch to one that is unprotected. Seems the Name Manager is only as protected as the worksheet you are currently on, but the button makes the whole process work perfectly either way.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,234

    Re: Using code to delete a named range

    Another thought: You need to deal with the case where the user enters a name that doesn't exist.

+ 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. [SOLVED] How to automatically delete named range by name?
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2013, 04:02 PM
  2. Delete Worksheets not on list or in named range?
    By Unpackedrope in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-09-2013, 04:12 PM
  3. [SOLVED] delete all oleobjects in named range
    By Willardio in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-24-2012, 02:47 PM
  4. Search Cell Value Delete if Not in Named Range
    By Julia55 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-04-2012, 05:39 PM
  5. Macro code to change cell range to named range
    By Orlic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2008, 11:51 AM

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