The article shows how to create an Excel drop down that allows users to select multiple items with or without duplicates.
Excel has come a long way since its inception and introduces more and more useful features with each new release. In Excel 365, they've added the ability to search within data validation lists, which is a huge time-saver when working with large sets of data. However, even with this new option, out-of-the-box Excel still only allows selecting one item from a predefined list of options. But fear not, as there is a solution. By using VBA, you can create drop-down lists with multiple selections. With the ability to prevent duplicates and remove incorrect items, this feature can streamline data input and improve accuracy in your Excel spreadsheets.
How to make Excel drop down with multiple selections
Creating a multi-select drop down list in Excel is a two-part process:
- First, you make a regular data validation list in one or more cells.
- And then, insert the VBA code at the back end of the target worksheet.
It also works in the reverse order :)
Create a normal drop-down list
To insert a drop down list in Excel, you use the Data Validation feature. The steps slightly vary depending on whether the source items are in a regular range, named range, or an Excel table.
From my experience, the best option is to create a data validation list from a table. As Excel tables are dynamic by nature, a related dropdown will expand or contract automatically as you add or remove items to/from the table.
For this example, we are going to use the table with the plain name Table1, which resides in A2:A25 in the screenshot below. To make a picklist from this table, the steps are:
- Select one or more cells for your dropdown (D3:D7 in our case).
- On the Data tab, in the Data Tools group, click Data Validation.
- In the Allow drop-down box, select List.
- In the Source box, enter the formula that indirectly refers to Table1's column named Items.
=INDIRECT("Table1[Items]")
- When done, click OK.
The result will be an expandable and automatically updatable drop-down list that only allows selecting one item.
Tip. If the method described above is not suitable for you for some reason, you can create a dropdown from a regular range or named range. The detailed instructions are here: How to create Excel data validation list.
Insert VBA code to allow multiple selections
This is the core part of the process that does the magic. To turn a regular single-selection picklist into a multi-select dropdown, you need to insert one of these codes in the back end of your target worksheet:
- VBA code for multi-select drop down with duplicates
- VBA code for multi-select drop down without duplicates
- VBA code for multi-selection dropdown with item removal
To add VBA code to your worksheet, follow these steps:
- Open the Visual Basic Editor by pressing Alt + F11 or clicking the Developer tab > Visual Basic. If you don't have this tab on your Excel ribbon, see how to add Developer tab.
- In the Project Explorer pane at the left, double-click on the name of the worksheet that contains your drop-down list. This will open the Code window for that sheet.
Or you can right-click the sheet's tab and choose View Code from the context menu. This will open the Code window for a given sheet straight away.
- In the Code window, paste the VBA code.
- Close the VB Editor and save your file as a Macro-Enabled Workbook (.xlsm).
That's it! When you go back to the worksheet, your drop-down list will allow you to select multiple items:
VBA code to select multiple items in dropdown list
Below is the code to make a data validation list that allows selecting multiple items, including repeated selections:
How this code works:
- The code enables multiple selections in all drop down lists on a particular sheet. You do not need to specify the target cell or range reference in the code.
- The code is worksheet specific, so be sure to add it to each sheet where you want to allow multiple selections in drop down lists.
- This code allows repetition, i.e. selecting the same item several times.
- The selected items are separated with a comma and a space. To change the delimiter, replace ", " with the character you want in DelimiterType = ", " (line 7 in the code above).
Note. The same character cannot be used as both the delimiter and part of the dropdown items. In our code, the default delimiter is a comma followed by a space (", "), so this combination of characters should not appear anywhere within the dropdown items themselves to avoid conflicts. If you change the delimiter to a single space (" "), bear in mind that the code will only function correctly for single-word items, failing to handle multi-word items containing spaces.
Excel multi-select dropdown without duplicates
When selecting from a large list, users can sometimes pick the same item more than once without noticing. The code below solves the problem of duplicates in a multi-selection data validation drop down list. It lets users pick a particular item only once. If you try to select the same item again, nothing will happen. Pretty cool, right?
Multi-selection dropdown with item removal
When users need to select multiple options but can make mistakes or change their minds during the selection process, a multi selection dropdown that allows for the removal of incorrect items can be a lifesaver.
Consider a scenario where you need to assign multiple tasks to team members using a drop-down list. With Excel's default functionality, the only way to remove an incorrectly assigned task is by clearing the entire contents of the cell and starting over. With the ability to remove individual items from the selection, the team can effortlessly modify task assignments without confusion or errors.
The code below implements the item removal functionality in a simple and intuitive way: the first click on an item adds it to the selection, and a second click on the same item removes it from the selection.
The below demo highlights how the multi selection dropdown with removal functionality works in Excel. The users can select multiple options from the data validation list and make adjustments on the fly. A streamlined and effective approach to managing selections!
How to make a multiple selection dropdown with custom delimiter
The character that separates items in the selection is set in the DelimiterType parameter. In all the codes, the default value of this parameter is ", " (a comma and a space) and it is located in line 7. To use a different separator, you can replace ", " with the desired character. For instance:
- To separate the selected items with a space, use DelimiterType = " ".
- To separate with a semicolon, use DelimiterType = "; " or DelimiterType = ";" (with or without a space, respectively).
- To separate with a vertical bar, use DelimiterType = " | ".
For example, if you change the delimiter to a vertical slash, your multi-select picklist will look as follows:
How to create dropdown with multiple selections in separate lines
To get each selection in a separate line in the same cell, set DelimiterType to Vbcrlf. In VBA, it is a constant for the carriage return and line feed characters.
More precisely, you change this code line:
DelimiterType = ","
to this one:
DelimiterType = vbCrLf
As a result, each item that you select from the dropdown list will appear in a new line:
How to create multi-select dropdown for specific columns, rows, cells and ranges
All the codes described in this tutorial work across an entire sheet. However, you can easily modify any of the codes, so it only applies to specific cells, rows, or columns as needed. For this, find this line of code:
If rngDropdown Is Nothing Then GoTo exitError
Add immediately after it, add a new line specifying where to allow multiple selections, as explained in the below examples.
Multi-select drop-down for specific columns
To allow selecting multiple items in a certain column, add this code:
If Not Destination.Column = 4 Then GoTo exitError
Where "4" is the number of the target column. In this case, the multi-select dropdown will be only enabled in column D. In all other columns, dropdown lists will be limited to a single selection.
To target several columns, specify their numbers using this code:
If Destination.Column <> 4 And Destination.Column <> 6 Then GoTo exitError
In this case, the multi-select dropdown will be available in columns D (4) and F (6).
Multi-selection dropdown for certain rows
To insert multiple drop-downs in a specific row, use this code:
If Not Destination.Row = 3 Then GoTo exitError
In this example, replace "3" with the row number where you want to enable multi-select dropdowns.
To target multiple rows, the code is as follows:
If Destination.Row <> 3 And Destination.Row <> 5 Then GoTo exitError
Where "3" and "5" are the rows where selecting multiple items is allowed.
Multiple selections in specific cells
To enable multiple selections in particular cells, add one of the below code lines.
For a single cell:
If Not Destination.Address = "$D$3" Then GoTo exitError
For multiple cells:
If Destination.Address <> "$D$3" And Destination.Address <> "$F$6" Then GoTo exitError
Just remember to replace "$D$3" and "$F$6" with the addresses of your target cells.
Multi-select drop-down for specific range
To limit your multi-select dropdown to a particular range, replace this line of code:
If Intersect(Destination, rngDropdown) Is Nothing Then
with this one:
If Intersect(ActiveCell, Range("C3:D10")) Is Nothing Or Intersect(Destination, rngDropdown) Is Nothing Then
The range of interest is specified directly in the code (C3:D10 in the above example). This modification offers a more efficient approach to handing ranges - instead of individually listing 16 cells, you use a single range reference.
How to enable multi-selection functionality in protected sheet
To enable a multi-select dropdown functionality in a protected worksheet, simply insert the following code into the sheet where you've added the primary code. This "protected sheet" code should be added after the main code.
Before adding this code to your worksheet, remember to replace "password" with the actual password you used to protect the sheet. And this is the only change that needs to be made. The code will automatically detect the presence of a dropdown list in a given cell and allow editing of that cell. In all other cells, editing will remain restricted.
Note. Please be aware that including your real password in the code could lead to a security risk. To ensure the safety of your workbook, store it in a secure location that is protected against unauthorized access or use.
So, there you have it - an Excel dropdown list with multiple selections. Adding this awesome feature to your spreadsheets will increase the accuracy of your data input and help you get your work done faster!
Practice workbook for download
Multi-selection dropdown - examples (.xlsm file)
619 comments
Alexander,
This is awesome, having an editable list of items in a data validation field is something my internal customers require. I appreciate both the example workbook and the VB behind it. I have learned a ton.
However…
I have implemented the "Item removal" version in my workbook and it does what I want. However, if I use that data validation in a cell of my own table I get a Data Validation alert as soon as a second value is chosen.
Very simple example. Workbook with two sheets. Sheet two contains the table "Years" and consists of a single column "Years". The rows have a single year, such as 2024, second row 2025, and so on. Sheet one contains a two column table. First column is "Thing", second column is "Year(s)". The data validation is List with "=INDIRECT("Years[Years]")" as the Source. One reason I want to use a table is that there can be any number of rows from 49 to over 12,000. But I'd rather not set every row up in advance. Do you have any suggestions?
I found a way to ignore all errors by putting:
Application.ErrorCheckingOptions.BackgroundChecking = False
In the workbook open event and
= True
in the Before Close event.
I don't love this because I don't want to be changing global user preferences for them.
Hello Lorin!
Unfortunately, I was not able to reproduce your problem in my workbook. And I can't check how the drop-down list works in your workbook and whether the macro code is set correctly.
Hi, Thankyou for sharing this. I have been using the ‘Multi-selection dropdown with item removal’ code on my worksheet successfully! I am now setting up a Data Entry User Form and was wondering whether I can use this code to have a Combo Box behave in the same way?
Hi! This VBA code only works with a drop down list.
Thanks Alexander.
Are you aware of any ways or able to point me in the right direction as to how I might get this or similar functionality with a user form? Otherwise I am thinking I would need a separate box for each instance to collect the data.
Regards.
Hello Alex,
I am really grateful for the information that you have provided, in such a detailed manner. Something that I would also like to know is that is there any code that we can modify/write to limit the number of selections made by the user?
Hi! You can try limiting the number of separators that are used in the results of a dropdown list with multiple selections.
Thank you, appreciate the information and level of detail.
Hello, I am trying to do multi-selections in a protected sheet but I am getting an error (Ambiguous name detected: Worksheet_SelectionChange). I think I may be putting the protected sheet code in the wrong place. Can you assist me in combining the multi selection and protected sheet code? Thanks!
Hello Lauren!
I am unable to insert the code into your workbook. Carefully follow the instructions given in the article. Also, this issue has been discussed many times in the comments below.
Hello,
Thank you for sharing this guidance and code.
Is there a way for the COUNTIF function to pick up when an option has been selected amongst others? For example, on your scenario to pull a count for how many times egg and cheese were selected in total?
Thanks
Claire
Hello Claire!
If you split the text string into individual cells using these methods: Split string by delimiter or pattern, separate text and numbers or by using the TEXTSPLIT function, then you can count the words using the COUNTIF formula or the SUMPRODUCT formula.
Thank you for this great tutorial!
I am working on using it in a table with tasks where ressources are selected for each task. I would like to use the drop-down list for the ressource(s) for each task. But when I copy the cell with the list (or drag the fill handle), I only get the value in the next cell and not the list. IS it possible to copy the cell with the list to other cells and still keep til dropdown list in the new cell?
I have used the vba code for "Multi-selection dropdown with item removal" with DelimiterType = vbCrLf.
Thank you for your help!
Hello Peter!
If I understand your task correctly, this guide may be helpful: How to copy drop down list in Excel.
I tried this and can still only select 1 item.
Hi, thank you so much for this important code and explanation. But I would like to know how to connect the multi-select drop down list (which includes 3 names for an example) automatically with another cells. Let's say that I have a database table includes names (column A) and salaries (column B), how can I make a multi-select drop down list for names (column C) and the next cell (column D) shows their salaries in the same sequence automatically?
Hello Sam!
You must split text string created by the multi-select drop-down list into individual cells. Then use VLOOKUP or INDEX MATCH formula to find the salary value for each name. Then use the TEXTJOIN function to combine the salary values.
Hello! It worked, but... I'm no coder, just a rookie and while I got the multiple options on the list to work all right (very excited), when I tried to remove them again they kept reappearing. I selected the option where you can remove them again afterwards. I have clicked on item in the drop down a second time and tried removing them manually.
Fabulous - thank you!
I implemented 'How to create dropdown with multiple selections in separate lines'
and 'How to make a multiple selection dropdown with custom delimiter'
Icing on the cake would be to allow fill-ins as well as multi-selections - can this be done?
Hi! We don't do VBA code customizations, but you can try to do it yourself.
This is VERY helpful! Is it possible to alphabetize the list in the cell after each selection?
Hello Krissi!
In order to sort the words in a text in a cell that has been created using a drop-down list, you need to use a special VBA macro.
Hi! Amazing post! Saved me a lot of time :)
I just wanted to follow up on Krissi's comment. What would be the addition to the existing VBA macro that we inputted to create the multi-select dropdown so that the selections sort alphabetically and not in the order they were selected.
Thank you so much!
Hello Andres!
To sort the result of a multi-select drop down list, you can add this code:
Dim words() As String
Dim sortedText As String
Dim i1 As Integer, j1 As Integer
Dim temp As String
' Split the text into words
words = Split(Destination.Value, DelimiterType)
' Sorting words
For i1 = LBound(words) To UBound(words) - 1
For j1 = i1 + 1 To UBound(words)
If words(i1) > words(j1) Then
temp = words(i1)
words(i1) = words(j1)
words(j1) = temp
End If
Next j1
Next i1
' Combining sorted words into a string
sortedText = Join(words, DelimiterType)
' Write the sorted text back to the destination cell
Destination.Value = sortedText
Insert this code before the lines of code
End If
End If
exitError:
This works perfectly! Is there a way to apply a custom sorting rule instead of in alphabetical order?
Say I wanted a list of names like Tim, Bob, Bill, Chelsea, Kora, and Xander. But I wanted Xander to always appear first if selected, then Kora, then Tim, Chelsea, and so on.
Is there code I could insert to sort the selected data from a custom ordered list (maybe a column on another hidden row or sheet?)
Thanks!
Hi! Your request goes beyond the advice we provide on this blog. You can try to do it yourself using VBA.
Thank you for this! This is exactly what I needed and explained greatly, but a question:
I now have the code so that the choices are seperated by ", " & vbCrLf So that it puts the words under each other in the table. But when I wanted to use the filter in the table it put all the words in the cell together. Is there a way to change the code so it reads every choice as a separate? Or maybe a different macro somewhere? I couldn't find it.
Like a code that says that words in a certain colom are divided by a "," and the filter has to read the words separated by "," as different words. Even if they are in the same cell. So the filter shows all the cells (and rows in the table) that contain the 1 word I am filtering on.
It seems do-able but I don't have the skill and knowledge yet by far to figure it out.
Hello Martha!
You can use the Excel Filter feature to filter cells that contain or exclude a specific character or word anywhere in the text. For the detailed instructions, please see: How to filter text values.
Just like the other comments it works initially and then refuses to work after I save and close (opened the next day and multi select doesn't work) I've looked into the trust center and still nothing. Thoughts?
Hi! Since I can't see your file and your actions, I can only recommend this article: How to enable and disable macros in Excel.
Hi Alexander - This works great! Where multiple selections are set to go to the next line - is it also possible to add a custom symbol (ie. ;) after each response as well ... combining the new line option with the custom delimiter?
Hi! If I understand you correctly, you can use multiple characters in the delimiter. For example:
DelimiterType = ";" & vbCrLf
It was successful at first. However, when I closed the file and reopened, the multiple selection no longer worked. When I tried to view the VBA code in the Code Window, I could not even open the Code Window. I am sure about saving it correctly as .xlsm file.
Hi! I hope you find these recommendations useful: How to enable and disable macros in Excel.
Can checkbox come in the drop down list? it will be helpful
Hi! You cannot insert a checkbox using a drop-down list. But you can insert tick symbol in the cells that you use to create the drop-down list. Then you will be able to select those symbols in the dropdown list. However, don't forget that you must use the Wingdings font in the cell with the dropdown list.
For more information, please read: 6 ways to insert a tick symbol and cross mark in Excel.
I think it is possible - by combining data validation with ListBox (ActiveX) or ComboBox (ActiveX).
Hi! You can do it using VBA code. But it is impossible to do it using standard Excel tools.
Hey thanks for the code, its indeed helpful. But i just noticed that the options in target cells dont automatically appear as a dropdown list. Instead i am having to key in a letter and then the list displays all contents of the source list that contains the key word i typed. How can i have a drop down list with all items from the source list displayed for me to choose from?
Many thanks in advance for the support. Much appreciated.
Hi! The provided VBA code allows you to write multiple values into a cell that is selected in the drop-down list. It does not affect how the dropdown works. You can read how to create a drop-down list here: How to create drop down list in Excel: dynamic, editable, searchable.
This article has been a lifesaver! I do have a question about how I can have the macro applied to all worksheets in my workbook without having to manually add the macro each time I create a new worksheet? I have to make a new worksheet monthly and it would save a bit of time if I could have it apply automatically. Thanks
Hello Brandy!
The Private Sub Worksheet_Change event works only on one worksheet where the VBA code is written.
does it work when the dropdown table/list is in a separate spreadsheet?
Hello Nikki!
The multiple select macro works with any properly working dropdown list. You can use any of the methods described here: Create drop down list in Excel: static, dynamic, editable, searchable.
Thank you, I tried this code & it was brilliant. Since next day the code is not working Not sure why?
Hello Nikki!
Make sure that you have saved the file in which this macro is stored in the correct way. Read more: How to save macros.
You may also find these instructions helpful: How to enable and disable macros in Excel.
Hello Alex,
Thanks for getting back to me. is there any code that i can use to run Macro automatically when i open excel workbook? Thanks