+ Reply to Thread
Results 1 to 13 of 13

Multi-select picklist using Data Validation

Hybrid View

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    15

    Multi-select picklist using Data Validation

    I need to create a multi-value picklist in my spreadsheet. I read a previous post and copied/pasted the VB code into my spreadsheet, but I cannot get it to work. Thanks in advance for any assistance. Spreadsheet attached.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Multi-select picklist using Data Validation

    HI

    Worked for me. What exactly are you doing?

    rylo

  3. #3
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Multi-select picklist using Data Validation

    Hi,

    Found out it was working for me as well. Here's the hook...it only works on one column/spreadsheet. I have three picklist columns in my spreadsheet -- C, D, and E -- so when I was testing, I was clicking in column D which is the one I want to use a multi-select option in and it wouldn't work. I just happened to try column C and it worked! Lesson learned: if you have more than one picklist column, you can only make one multi-select and it has to be the first picklist column using Data Validation.

    Thanks for responding.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Multi-select picklist using Data Validation

    Hello prgates,

    Use this version of the macro. This has been updated to prevent duplicates in the list.
    
    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
        Dim rngDV As Range
        Dim oldVal As Variant
        Dim newVal As Variant
    
            On Error GoTo exitHandler
            
            If Target.Count > 1 Then GoTo exitHandler
            
            Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
            
            Application.EnableEvents = False
            
                If Not Intersect(Target, rngDV) Is Nothing Then
                
                    newVal = Target.Value
                
                    Application.Undo
                    oldVal = Target.Value
                
                  ' Clear the cell is new value is "".
                    If IsEmpty(newVal) Then
                        Target.Value = newVal
                        GoTo exitHandler
                    End If
                
                  ' Do not duplicate a selection.
                    Select Case InStr(1, oldVal, newVal)
                        Case 0
                            If IsEmpty(oldVal) Then
                                Target.Value = newVal
                            Else
                                Target.Value = oldVal & "," & newVal
                            End If
                        Case Is > 0
                            Target.Value = oldVal
                    End Select
                
                End If
    
    exitHandler:
            Application.EnableEvents = True
      
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Multi-select picklist using Data Validation

    Thanks so much!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Multi-select picklist using Data Validation

    Hello prgates,

    You're welcome.

  7. #7
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Multi-select picklist using Data Validation

    Question...

    How do I marked my posted "Solved"? I tried typing SOLVED as a reply and it told me my text was too short. Should I just edit the post and typed SOLVED?

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Multi-select picklist using Data Validation

    Hello prgates,

    Here is how...

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  9. #9
    Registered User
    Join Date
    08-01-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Multi-select picklist using Data Validation

    Hi! I am trying to create a multi-select pick list and came across this post. I'm not exactly sure what to do with the macro posted above. Can someone explain. I am relativley new to creating lists!

    I greatly appreciate any help you can provide!! Thank you!!

  10. #10
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Multi-select picklist using Data Validation

    Right-click on the spreadsheet tab
    Select View Code
    Paste the VB code in the text box
    SAVE and test

  11. #11
    Registered User
    Join Date
    08-01-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Lightbulb Re: Multi-select picklist using Data Validation

    Got it!! Thank you prgates!!

  12. #12
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Multi-select picklist using Data Validation

    Hello Qdogsmom, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following and keep it in mind for future posts. Thanks.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

  13. #13
    Registered User
    Join Date
    03-16-2013
    Location
    Kabul
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    1

    Even though the thread is old, I would like to share with you my solution

    I solved the data validation multiple select issue by creating a small form that I can use to display the values the users need to select.
    This method presents other advantages, such as: you can use it on virtually any number of columns, you are able to control how it behaves, allowing you to set the selection as multiple or single, it can also be used to allow users to input free text, and it provides a way for the admin to pass some information, guidance, etc to the users. It also presents the advantage of not being overwritten by users when copy-paste occurs, a problem for the classic data validation feature in Excel.
    data_validation_form.png
    The example was created in Excel 2010 and I tested it on a 2003 version with the Office Compatibility add-in installed, without getting any errors.
    Please find attached the example and detailed explanations of how to use it.
    P.S.
    I only posted this solution because the ones that I came across didn't solve the problem for more than one column and I thought it might help some people out.
    DataValidationForm.xlsm
    DataValidationForm_howto.docx

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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