+ Reply to Thread
Results 1 to 6 of 6

Can't cycle through different ranges and delete same name.

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Can't cycle through different ranges and delete same name.

    Attached sheet has three DropLists (Cols D, H and L) containing Operator names, populated by the Ranges in Cols O - Q.
    Same name can appear in more than one list.
    When a name is selected, need to remove the name from ANY Range it appears in, so the same operator cannot be assigned twice.

    Code below should loop through Col D, H and L. If it finds a name, it should loop through Cols O - Q looking for every instance of that name. When it finds a match, it adds it to an Array. When it finishes searching for a match to Col L the array should hold all instances of each name selected, which should then be deleted from Cols O - Q, and the remaining names 'shuffled up' to close the gaps, so none of the DropLists will now include any name selected already.

    Can't see why it is isn't working?

    Please Login or Register  to view this content.
    All solutions, suggestions and alternatives welcome as ever.

    Ochimus
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Can't cycle through different ranges and delete same name.

    Place this macro in the code module for the worksheet. The macro is based on the 3 instructions you listed in the "SCHEDULE" sheet. Since the macro is triggered automatically upon selection in D2, H2 or L2, the "Prevent Duplicates" button is no longer needed.
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: Can't cycle through different ranges and delete same name.

    Mumps,

    Many thanks for the prompt response, but unfortunately it isn't quite working?

    The attached uses your Sheet Change trigger.

    If you select Operator 3 as "Red", the Worksheet Change removes it from the Operator 2 list (Col P), but not from Operator 1 (Col O).
    It also leaves it in the Operator 3 list itself (Col Q) - apologies if that step was not spelled out clearly enough in the original post.

    To reiterate, if you select any name in D, H or L it needs to disappear completely from O - Q.

    Ochimus
    Attached Files Attached Files

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Can't cycle through different ranges and delete same name.

    Try:
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: Can't cycle through different ranges and delete same name.

    Mumps,

    Looks to work perfectly!

    Support much appreciated. Can now mark this as Solved and hope it can help many others in turn.

    Just as a matter of interest, any idea why the "Union R1C1" approach I tried originally fell over?

    Ochimus

    Ochimus

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Can't cycle through different ranges and delete same name.

    You are very welcome. To be honest, I'm not sure why the "Union R1C1" approach didn't work for you.

+ 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] Can't delete named ranges using VBA
    By frankt68 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-02-2021, 05:38 AM
  2. [SOLVED] Spinbutton to cycle through named ranges
    By ymmotteov in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-02-2018, 06:41 PM
  3. Replies: 2
    Last Post: 08-25-2017, 03:46 AM
  4. [SOLVED] Delete Cell Ranges
    By skhari in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2012, 07:52 AM
  5. Cycle Through Sheets & Sorting Named Ranges
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2012, 09:53 PM
  6. Delete Hidden Name Ranges
    By bleeg10 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2011, 03:23 PM
  7. [SOLVED] How do I keep result from 1 iteration cycle to use in next cycle?
    By sgl8akm in forum Excel General
    Replies: 0
    Last Post: 07-27-2006, 03:35 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