Unique Strings while selecting multiple Items from a Drop down in a Cell

hariready

New Member
Joined
Sep 11, 2014
Messages
1
Hi. I was trying to create a drop down list, where the user could select multiple options from the list, but still the options selected must be unique within a Cell. For Instance: if a Dropdown has A, B, C as values, selecting A and C is a valid selection, but selecting A, C and A is not.

I did manage to create a multi-select drop down, (which is a comma separated strings) but could not implement the unique string constraint. Any ideas
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Try this:-
NB:- The validation list is set in "B1" , Alter to suit !!!!
NB:- This code enables multiselections from a Validation Drop down list.
In order to clear the selections I have added the word "Clear" in the Validation List to enable the List to be reset. (Please do the same)
Code:
Option Explicit
[COLOR="Navy"]Dim[/COLOR] Str [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
Private [COLOR="Navy"]Sub[/COLOR] Worksheet_Change(ByVal Target [COLOR="Navy"]As[/COLOR] Range)
[COLOR="Navy"]If[/COLOR] Target.Address(0, 0) = "B1" [COLOR="Navy"]Then[/COLOR]
    Application.EnableEvents = False
    [COLOR="Navy"]If[/COLOR] Not Target = "Clear" And InStr(Str, Target) = 0 [COLOR="Navy"]Then[/COLOR]
       Str = Str & ", " & Target
            
        [COLOR="Navy"]End[/COLOR] If
   [COLOR="Navy"]If[/COLOR] Target = "Clear" [COLOR="Navy"]Then[/COLOR]
         Str = ""
    [COLOR="Navy"]End[/COLOR] If
Target = Mid(Str, 2)
Application.EnableEvents = True
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 

Watch MrExcel Video

Forum statistics

Threads
1,129,382
Messages
5,635,931
Members
416,888
Latest member
Mike66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top