+ Reply to Thread
Results 1 to 5 of 5

Deleting named ranges that do not have comments

  1. #1
    Registered User
    Join Date
    02-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    46

    Deleting named ranges that do not have comments

    In a workbook, I have a macro that I use to create a number (50-100+) named ranges. However, the names of these ranges will change somewhat frequently and I am trying to avoid having unused named ranges going forward as the macro is run additional times. What I am looking for is a method to delete all of the named ranges in a workbook that do not have a comment (or are simply not ones generated by the first macro) since I have some other named ranges that will not change that I have comments written for. Is this possible with VBA or is there another method that I can use to prune these unused ranges?

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Deleting named ranges that do not have comments

    As an avid proponent of named ranges (when used judiciously), I'm curious about why you'd need to create so many of them. I'm guessing there's a more efficient alternative.
    Can you either post a sample workbook or describe how the named ranges are being used?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    02-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    46

    Re: Deleting named ranges that do not have comments

    Ron,

    I don't have access to Excel at the moment, but in my workbook I have two different sheets. On the first sheet, there is a column with names and a column with part numbers. Each name is associated with multiple part numbers, so there could be anywhere from 4-10 row entries with the same name in the first column.

    On the second sheet, users input rows of information with the first column containing a valid name that exists in the first sheet's first column. Then, as you might expect, they enter in a part number in the second column that needs to be valid for the name entered in the first column. These part numbers contain a rather long string of letters and numbers so relying on manual entry is far from ideal. This is why I currently have a macro to create named ranges for each unique name entry so that once a name is entered the user can simply select a valid part number from a drop-down list.

    Lastly, since names are frequently added/removed from the first sheet, I need a way to remove any old, unused named ranges to keep the list manageable.

    If there is a simpler method to accomplish this I am certainly open to it. Hopefully, my description gave a good idea of what I am currently using.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Deleting named ranges that do not have comments

    OK...Here's what I did to mock-up your scenario:

    • Created a sheet named Lists
    • Put these values in A1:B17
    Please Login or Register  to view this content.
    • Convert that range to an Excel Table
    ...Select A1:B17
    ...Home.Convert_to_table
    ......Select a style
    ......Check: My table has headers and Click: OK
    ...Change the name of the table to: tblRefList
    ...Created Named Range for the data sections of the Name and PartNum fields (by using Formula.Create_Name)

    • Put these values in D1:D4
    Please Login or Register  to view this content.
    • Convert that range to an Excel Table
    ...Select D1:D4
    ...Home.Convert_to_table
    ......Select a style
    ......Check: My table has headers and Click: OK
    ...Change the name of the table to: tblNames
    ...Created Named Range for the data sections of the Name field (by using Formula.Create_Name)

    • Add a sheet name Input
    B3: SelectName
    C3: SelectPart

    • Create data validation for B4 that refers to the NameList named range


    • Select C4
    • Create a Dynamic Named Range that will contain only the part nums for the Name in Col_B
    ...Formula.Name Manager...Click: New
    ......Name: PartList
    ......Refers To: =OFFSET(PartNum,MATCH(Input!$B4,Name,0)-1,,COUNTIF(Name,Input!$B4))
    ......Click: OK

    • Create data validation for C4 that refers to the PartList dynamic named range.

    Copy B4:C4 down as far as you need.

    After selecting a name in Col_B, the dynamic named range associated with the Col_C input cell will reference and list the partnums for the Col_B name.
    That way, since a user can only select one DV cell at a time, you only need one (dynamic) named range.

    See attached file.

    Is that something you can work with?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    46

    Re: Deleting named ranges that do not have comments

    Ron, sorry for the belated reply but I have finally gotten a chance to take a look at your suggestion and am having some difficulty in implementing it.

    I currently have the following named ranges:

    Names - Unique list of allowable names listed on a sheet called "Employees"
    NameList - List of all names on a sheet called "Assignments"
    PartList - List of all parts on a sheet called "Assignments"
    Parts - A formula of =OFFSET(PartList,MATCH(Assignments!$B2,NameList,0)-1,,COUNTIF(NameList,Assignments!$B2))

    On the "Assignments" sheet, I then added data validation for column A to select a name (List, =Names) and in column B I added data validation to select a valid part (List, =Parts). The validation in column A works, however the validation in column B does not.

    I did not convert anything to tables as I am somewhat unclear as to what purpose it serves and was unsure of what you meant by "Created Named Range for the data sections of the Name field (by using Formula.Create_Name)" as it relates to the table.

    I have attached an example of what I have tried so far.
    Attached Files Attached Files

+ 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. Insert comments using data from cells in variable, named ranges
    By horariatersenha in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-13-2014, 04:22 PM
  2. [SOLVED] Deleting Hidden named ranges with vba code
    By GavinMcL in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-11-2014, 09:07 AM
  3. deleting named ranges
    By Hein in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-28-2009, 09:27 AM
  4. Deleting Named Ranges
    By Grant Reid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-27-2005, 11:05 AM
  5. Deleting many named ranges
    By Tom Hayakawa in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-28-2005, 06: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