Drop Down- Multiple Selections

nldstorm

New Member
Joined
Sep 20, 2009
Messages
15
I am trying to create a drop down menu whereby a user can select multiple values, which are then placed into the same cell using a coma. For example, the drop down list would contain companies 1001, 1002, 1003 and 1004 (actually this drop down list would have about 200+ companies). I would like to have an option so that the user can select, for example, companies 1002 and 1004. The cell result should then be 1002, 1004. I have code that allows me to do this however each value must be selected serperatly causing the user to go back into the drop down list. I would like to have the user select all the companies at one time.

Hope you can help.

Thanks
 

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.
you should be using a ListBox (from the control toolbox) rather than a combobox. Listboxes allow for multiple selections. Below is some sample code that you can paste to your ListBox that will put in the selections into Cell B1. In addition, you'll have to update the following properties of the Listbox in design mode:

ListFillRange: (put in here the range where you companies are listed) i.e. A1:A200

MultiSelect: 1-fmMultiSelectMulti


Code:
Private Sub ListBox1_Change()
 
Dim myString As String

For i = 0 To ListBox1.ListCount - 1
    
    If ListBox1.Selected(i) = True Then
        myString = myString & ", " & ListBox1.List(i)
    End If
Next
    
Range("B1") = Mid(myString, 3)
 
End Sub
 
Upvote 0
Thanks a lot for the quick follow up. Is there any way you can guide me a bit more how to create the box and input the code? As you can see from this request I am a beginner with all of this.

Thanks again for your help.
 
Upvote 0
1. from the menu bar: View\Toolbars\Control Toolbox
2. Select the 'List box' icon from the Control Toolbox
3. Drag your cursor to where your list box is to be located on your sheet
4. right-click the listbox, select 'view code' (paste the code I provided above)
5. right-click the listbox, select properties:
a) ListFillRange: (put in here the range where you companies are listed) i.e. A1:A200

b)MultiSelect: 1-fmMultiSelectMulti

6. select the design mode icon on the Control toolbox to exit design mode.

7. test the listbox to make sure it works the way you would like.
 
Upvote 0
Thanks. I think that ive got it working. But am I able to use the selected values in pivots and filters?
 
Upvote 0
now i'm confused. what was the purpose of your original post? do you just want to filter a table based on a selection? what is your ultimate goal?
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,755
Members
449,049
Latest member
excelknuckles

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