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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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
 
Upvote 0

Forum statistics

Threads
1,217,755
Messages
6,138,422
Members
450,136
Latest member
Tabako1960

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
Back
Top