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)
622 comments
Thanks so much for the helpful walk-through - this is the exact fix I've been after for my work spreadsheet!
However, after trying all 3 code strings separately in the backend of the workbook, none of them have worked :( I'm trying to figure out why this might be, as I've followed the steps above, pasted the code into the right place and the file was already a macro-enabled workbook.
When you paste the code, do you need to delete any existing code that's already in the code window? Or just paste before/after?
The only thing that appears different is that that a few horizontal lines appear, separating parts of the code. Could this affect the output?
Thanks again
Hello! When you insert code, pay attention that there are no macros with the same names. If you are not using any other macros, delete all the code and then insert the code for multiple selections. You can also download the sample file linked at the end of this article.
It worked!!! I am so happy!!! You & your team’s patience and dedication at work is an invaluable gift for all of us and we are truly grateful.
Wishing you and your loved ones continual good health and safety. Kind regards from Malaysia :)
Great Info. The question I have may have already been answered but there are 432 responses so I more than likely missed it. I have two issues. (1) I want to have 3 separate dropdown lists for 3 specific columns in my worksheet (List 1 for column 1; List 2 for column 2, and each list contains separate data etc.) and I want to adapt your VB code so that there is NO Duplication AND the ability to remove an entry - PLUS - I have a 4th separate dropdown list for a 4th specific column that I would like to ALLOW duplicates AND the ability to remove an entry. I think that's quite a lot in one visual basic code, but if it can be done, I'd be very happy. I would be extremely happy if (2) there was a way to sequentially number the entries in ONE COLUMN ONLY as they are entered AND for the numbering to reset if I have to remove or replace an entry. I'll be happy to show you a sample of what I need the dropdowns and code to accomplish if needed.
Thanks
Hi! In the drop-down list, you can choose to allow duplicates in individual rows, columns, or cells of your table. Duplicates are not allowed in other cells. Have a look at the above article for instructions. You must use separate code to prevent editing or removing individual cells. You can use these instructions as well: How to lock and unlock cells in Excel.
Hi, sorry if this has been asked before, I didn't find it in the comments.
Can you make a dropdown list to have a single selection or multiple selection from the same list, depending on the value of adjacent cell. For example:
1) In column A is a simple dropdown list with two possible values: let's say "value 1" or "value 2"
2) Depending on the selected option in cell A1, I want the dropdown list in B column to have the same dropdown list options but be able to select one or multiple options:
- if A1 is "value 1", you can select single option in B1 dropdown list
- if A2 is "value 2", you can select multiple options in B1 dropdown list
Fantastic help and many thanks.
Hi! Modifying the macro code is necessary for doing whatever is desired. We do not modify the code at the request of users. You can try to do it yourself.
I'm not able to attach a picture of my issue, however, I have copied the code into the Worksheet/SelectionChange page. I continue to be prompted to name a Macro. Then I get a Compile Error: Ambiguous name detected: Worksheet_SelectionChange. Any ideas? I have Windows 11.
Hi! I cannot know how you installed the code. Follow the instructions in the article above carefully. In the workbook linked at the end of the article, you can see an example of how the code works.
Hi
Thanks really finding your site useful.
Have been quite successful with your guidance, so to take it further
, how can I get my drop down boxes to reset when I want to put a new entry in from the start, ie enter a name drop down gives age and favorite colour. then enter a new name and boxes return to new entries not the previous ones.
Hope this makes sense
Thank you
Hi! If I understand correctly, you can clear a cell with a drop-down list just like any other cell - by using the DEL key.
Please ignore my last question! just seen the answer in the main body - I happy went and implemented before reading the WHOLE post. Apologies
Is there any way I can amend the code to target only one specific dropdown box?
I have a number of them on the same sheet.
Thanks so much for this - its an invaluable resource.
Hi! To allow multiple selections for only one specific dropdown box, use these instructions from the article above: Multiple selections in specific cells.
Hi! Really appreciate the article and code. Thanks!
The task is to create a product list with fixed prices, for which you can add optional accessories at additional cost. One column for 'Product' , one for 'Price' and one for 'Accessories'.
What I want to do, is to make the accessories column a drop-down list (sourced from a master accessories and prices table) where I can add whichever accessories I wish, and the total price automatically updates depending on the attachments selected. Should also support accessory/item removal in case of mistakes.
Thanks in advance!
Hi! If I understand your task correctly, the following tutorial should help: Create drop down list in Excel: static, dynamic, editable, searchable. To get the price for the selected accessories, you can use the VLOOKUP function. I hope my advice will help you solve your task.
Hi there, is it possible to have the final result of the multiple selection arranged in alphabetical order?
Hi! See the comments below. The answer has already been given. You will need to use a separate macro to sort the text string.
Hi,
Thanks for this post, was really helpful and clear.
I used it for a file I created and used a drop down list with multiple selection, and I did the change in the code so it will be presented one below the other and not separated with ","
But, for some reason, sometimes some of the cells with the data gets tempered and it jumps and being separated by space.
example:
1. when it's correct:
Kitchen
Bathroom
Room
2. When it's changed (I don't know what causes this or how to even try to fix it):
Kitchen Bathroom Room
I tried using alt+Enter, it shows an error: "this value doesn't match the data validation restrictions defined for this cell."
another thing is that this is a multiple selection WITH option to remove. but when it gets tempered - selecting for removal doesn't work - it adds it again.
Hope I explained this clearly and that someone can help me with it.
Thanks,
Sheena
My mistake, when it's tempered, it just connects all the data: KitchenBathroomRoom like this.
Hi! If my understanding is correct, you can see the working code on the "Selections in Separate Rows" worksheet in the sample file that is linked to at the end of this article. Hope you’ll find this information helpful.
I downloaded the worksheet, and it doesn't allow multiple choice when I try to do it myself.
In my excel file, it does allow me to select multiple lines from the drop down and it indeed presents it to me one under the other.
But not sure why it sometimes gets tempered and gets out of order.
Hi! This sample file has 100% functionality. It is possible that it has macros disabled because it was downloaded from the Internet. It might help: How to unblock a macro blocked by Microsoft.
Hi, I also have their problem, and my macro is not blocked. The code works except from when I manually edit or enter the text without using the drop down menu by either using F2 and pressing enter or by clicking the formula bar and pressing enter. As long as there is more than one option selected when I press enter it will either think I've made a data validation error or if will remove all delimiters and continue to generate duplicates of the text everytime I try to remove the error unless I delete all the text in the cell.
so "kitchen, bathroom, Room" will turn into "kitchenbathroomRoom" then when I try to remove the "Room" it then becomes "kitchenbathroomRoom, kitchenbathroom" or if I try to remove "Room" from "kitchen, bathroom, Room" it becomes "kitchen, bathroom, Room, kitchen, bathroom"
Hi! Your problem has been discussed many times in the comments. The solution to this issue is also described in the article at the end of the second section. Please read it carefully. The same character cannot be a delimiter and part of the dropdown items. In our code, the default delimiter is a comma followed by a space character (", "), so this combination of characters should not be used anywhere in the dropdown list items themselves to avoid conflicts.
Hi again, to clarify, I have no spaces in any of my drop down items, they are all single word items without a comma or space. I've made a brand new workbook to test it with items "test", "test2", "test3", and "test4"
There are no delimiters in any of the drop-down items. When I have 3 options selected and remove 1 of them, by manually pressing backspace on the text, it comes with a validation error. When I turn off the error notification, it brings back the removed item and duplicates the text that was remaining, so "test, test2, test3" becomes "test, test2, test3, test, test2" when I try to remove "test3" then becomes "testtest2test3testtest2" when I select the text and press enter
I am using the "Multi-selection dropdown with item removal" code
If you want to manually adjust the data in a cell, why do you need a dropdown list? Try doing it in a normal dropdown without multiple selection and you will get an error too. If you use the "Multi-selection dropdown with item removal" code, you can't get a text string with duplicates of "test, test2, test3, test, test, test2".
Wow, this does exactly what I wanted it to!
One question regarding putting a filter over columns with multiple items ticked. Say I have 2 different rows:
eggs
eggs, milk
When I filter this data I wish to just press on "eggs" and have them both be live, rather than displaying as two different options in the filter.
Is this possible? It is my first time using VBA code!
Hi! I don't really understand what the filter has to do with the theme of this article. You can learn more about Excel Filter in this article on our blog.
Hi so I created a multi cell drop down list but I need to do more.
1. In a different cell I need to show the items which was not selected in a my multi drop down list cell.
2. I need to sum up my chosen options from my multi drop down list and my items not elected
Hi! An Excel drop-down list with multiple selections creates a string of text in a cell that contains all the items that were selected. To do what you want, each item must be written in a separate cell.
Appreciate you posting this. Very helpful information and you helped me do exactly what I was looking to do. Essentially I was looking for Excel to mimic a function that MS Project does, which is assign resources to specific task items. I created a list of "Leads" or techs. Then applying you code. I utilized the code that included removal. I also added the column destination line as well as changing the comma delimiter with the drop line vbCtLf. It all works great. The one issue I have is, that when more than one name is selected, i get a data verification error. Doesn't matter if I am using the original comma delimiter or drop line. Data verification sees multiple names and marks it.
It's a minor issue and if the answer is no, it can't be fixed, I am fine with that. But because I'd prefer the cleanest code possible, I would like to ask. Is there a way I can correct the process above to allow me to select multiple names and not trigger a data verification error. That is without turning off data verification off completely. Even if I just got it to ignore errors for this one column of one workbook, that could work.
Aside from this minor issue, your code is great. Thank you for posting and sharing.
Hi! I don't know what changes you made to the code or what data you used for the dropdown list. Try downloading the sample file from the link at the end of this article and pay attention to the worksheet "Selections in separate lines". The code works without errors there.
Also make sure that the delimiter is not used in the list of values for the dropdown list.
When I hit "Enter" to move to the next cell, it is auto posting the drop-down items selected. Any script on stopping auto post-back?
Hi! I am not sure I fully understand what you mean. The macro doesn't change how the dropdown works, it just lets you select multiple values.
I am allowing customization within my dropdown list selection. So not allowing an error alert. The macro allows for me to select multiple items and allows for the customization until I move to the next cell. Then it duplicates the drop-down items selected.
It's almost like I need to allow for the error and stop the duplication of the new value. Does that make sense?
Hi! I don't really understand what kind of customization you are talking about. I can't understand and reproduce your problem. I recommend downloading the sample file from the link at the end of the article and see how the macro works.
Hi, the code appears to be working correctly and allows me to choose multiple items from my list; however, I am getting a note in the cell that says "data validation error" with a yellow diamond/exclamation and says "The value in this cell is invalid or missing. Click on 'Display Type Information' for specific details". The popup then says "Field Type Information, G2, Data Type: List, Restriction: Value must match one of the listed items."
Again, it appears to be working correctly, just want to get rid of this warning box!
Thank you!
Hi! Without seeing your data, it is impossible to give any recommendations. Check what data you are using for the drop-down list. It may be very long numbers or text strings with non-printable characters, dots, or commas. Such values may change when you copy and paste.
Hi, thanks for the step-by-step instructions, very helpful. I am experiencing the same issue as Emma.
The context is that I'm using multiple selection dropdown with a custom delimiter for a column that validates from a list, formatted as a table. However, after selecting multiple items from the list, the cell was showing Data validation error icon - a triangle with an exclamation mark, saying the restriction that 'Value must match one of the listed items.'
This may be because the multiple items with custom delimiter that were displayed upon selection do not match/part of the referred list/Table.
Again, everything is working, but the same question, how do we stop that data validation error icon from showing up?
Hi! I can't see your data, so in addition to the previous recommendations, I can only assume you're using a list separator character in your values.
Hi, thanks for responding. Yes that is correct, I am using " | " as a custom delimiter to separate selected items in one cell. So using the same example as yours under section 'How to make a multiple selection dropdown with custom delimiter', I would have Chocolate | Cinnamon on one cell, but there's Data validation error icon showing up on the left side of the cell.
Also, is there a possibility to set the selected items sorted by alphabetical order? For example, from the options eggs, cheese, breadcrumbs, so upon choosing the times, even though we select the items as such order, the cell will populate as breadcrumbs, cheese, eggs?
It would also be great if there's a way to show the dropdown as checkbox, so we can make multiple selections in one dropdown.
Thanks Alexander.
Hi! To sort the words in the text string that the drop-down list creates, you need a special VBA macro. Showing the drop-down list as a checkbox cannot be defined with a macro. We cannot modify Excel.
Can this be done with Excel Online which does not allow you access VBA?
I am trying to figure it out the same thing :( For me it works in the Excel App but when we open the spreadsheet in the Browser, it does not work.
This question has been asked many times in the comments. The answer is "No".
Hi!
I have a multi-select dropdown list with the ability to remove using your VBA code. Is there additional code available to automatically sort the selected list items alphabetically when they are selected instead of placing them in the order they were selected. For instance if I select items 1, 3, 5 but in the order of 5, 3, 1, they are listed as 5, 3, 1. I would like them to list as 1, 3, 5 despite the order I select them in.
Thanks!
Hi! This question has been asked before, and the answer was "no". The drop-down list creates a text string. You can try to sort it using an additional VBA macro.
Thank you, this code is really helpful. Our organisation, a charity, may want to make available at no cost an excel file that includes a modified version of this code. Can we do so? And, if so, how would you like to be credited?
I have a worksheet that requires 4 different multi drop down lists for 4 different columns. I have tried to replicate what i did for the first one but it does not like me changing the formula ie =INDIRECT("Table1[Items]") to =INDIRECT("Table2[Service]"). Can you only have one multi drop list?
Hi! If I understand your task correctly, these articles may be helpful: How to make a dependent (cascading) drop-down list in Excel and Create a dynamic dependent drop down list in Excel an easy way.
Hi, thank you for sharing the codes. In situations when you have a large list, is there a way that we can type the text and it automatically select the selection in the list? instead of having to go through the whole list to find that one selection.
And how can I use pivot table to organize all the entries without duplications.
Hi! The pivot table does not use the standard dropdown list. The code works only with the dropdown list.
Hi! If I understand your task correctly, the following tutorial should help: Create drop down list in Excel: static, dynamic, editable, searchable.