+ Reply to Thread
Results 1 to 9 of 9

Data Validation - Selecting multiple items with ability to deselect items

  1. #1
    Registered User
    Join Date
    01-09-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    54

    Data Validation - Selecting multiple items with ability to deselect items

    Hello,

    I have the following VBA to create a data validation list where the user can select multiple items, which are separated by a comma. The setback is that an item cannot be deselected. I am wondering how the code could be modified so that it has the functionality to deselect a selected item.

    Please Login or Register  to view this content.
    Thank you,

    Dan
    Last edited by Leith Ross; 03-10-2016 at 01:17 PM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data Validation - Selecting multiple items with ability to deselect items

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachements to open the upload window.

    View Pic
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    01-09-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    54

    Re: Data Validation - Selecting multiple items with ability to deselect items

    I've added a sample worksheet.

    Data Validation in A1. As of right now you can select multiple items. Would like the VBA modified so that you can deselect a selected value by simply clicking on it a second time.

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data Validation - Selecting multiple items with ability to deselect items

    I cannot paste code.

    But you only need to change two lines.

    But I found that you can simplify you code and remove most of your if then statements.
    Attached Files Attached Files
    Last edited by mehmetcik; 03-10-2016 at 04:58 PM.

  5. #5
    Registered User
    Join Date
    01-09-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    54

    Re: Data Validation - Selecting multiple items with ability to deselect items

    This did it!

    Thanks!

  6. #6
    Registered User
    Join Date
    01-09-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    54

    Re: Data Validation - Selecting multiple items with ability to deselect items

    Sorry to revise this post, but I found a flaw in my original VBA. Was wondering if anyone could investigate. As the coding stands, a user can select and deselect multiple values in the data validation list. However, things get messy when I introduce similar values. For example, if my list contains "Twins" and "Twins 2" and I select both of them in my data validation list, then I deselect "Twins" (by clicking it again), its leaves "2" in the data validation list. Looks like when you deselect a value it removes all like terms. Any thoughts on how this can be remediated?

    Thanks!
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data Validation - Selecting multiple items with ability to deselect items

    I wonder? Maybe we should use ", " as a delimiter in all cases.

    But then we would need to make sure that you could not select the last entry.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 03-11-2016 at 12:46 PM.

  8. #8
    Registered User
    Join Date
    01-09-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    54

    Re: Data Validation - Selecting multiple items with ability to deselect items

    Appreciate the help!

    This worked, but like you said you cannot deselect if there is only one value selected in the list. This is beyond me...

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data Validation - Selecting multiple items with ability to deselect items

    This is easily fixed.

    Please Login or Register  to view this content.

+ 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. omit menu items via data validation for multiple selections and multiple menus when select
    By themattyp503 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-03-2014, 12:16 AM
  2. [SOLVED] Need to count items in column that match multiple data items
    By bclucas55 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-27-2014, 10:03 AM
  3. Editing Code: Selecting multiple items in a cell via data validation
    By baker2145 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 06:13 PM
  4. Excel Data Validation - Select Multiple Items - Need to Apply Macro to Multiple Rows
    By kristynroll in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2012, 07:44 PM
  5. t Multiple Items from Excel Data Validation List
    By naflas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-11-2011, 09:47 PM
  6. Data Validation: items in one list relate to items in another
    By Paul D. Simon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2005, 05:05 PM
  7. Replies: 1
    Last Post: 06-24-2005, 12:21 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