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
Thank you so much for this. I do not know about VBA but the instructions are really clear and they work as needed.
Works just as I needed it to. Thank you so much for this and for including the extra versions too. At first I thought I wouldn't need them, then thought ok, I don't want duplicates, and then right, what I actually want is no duplicates with the easy ability to modify the list item by item. So cool to see these all being separately supported in an easy to use way. Thanks again!
Hello! Your coding has been super helpful at multiple points for a project I've been slowly improving upon for work on and off for a few years now, so, thank you so much for that!
On that note, is there a way the display of the dropdown selections can be forced to arrange in a specific way regardless of the order in which they were selected? This would make filtering much simpler for my project. For example: can they be ordered in alphabetical order or by the order in which they are displayed on the dropdown list?
Thanks and have a great day!
Nicole
Dear Alexander,
I am so impressed with this page, it's easy to understand, and mostly pre-empt the task and provide the solution. I was looking for this option for quite sometime, however mostly I got though google search, was partially solving my issues. However your solution over delivered. I wish you all the best .
Thanks,
Sukanta
Many thanks this helped me a lot
Hi again Alex, I am so dopey, I re-read your comments
"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"
and deleted the " " and it fixed it.
Hi Alex, I have booked marked your page and find your knowledge on excel the most useful and insighting. I have nominate 3 columns and am changing the DelimiterType form"', " to = "vbCrLf" however when i save it, close it then reopen it shows this in the column; Abusive Behaviour Towards StaffvbCrLfAlcohol on Premises.
Please advise what i am doing wrong.
Hi! See the corresponding paragraph in the article above. You can also see the sample code in the example file linked at the end of the article.
Hi Alexander,
This page is incredible! Thank you so much!
I'm having some trouble though isolating the multiple dropdown selection to one column. In your instructions, you said about adding the code "If Not Destination.Column = 4 Then GoTo exitError". The only thing I changed was 4 to 5 as that's the column I need the dropdowns in.
However, it is still affecting my whole worksheet, so if I go to a dropdown in column 6 (F) where I only want a single selection, it allows me to put in multiple selections.
Please can you advise where I've gone wrong and offer a solution?
Sorry, I should have looked at the previous comments! For those that are having similar problems, I resolved the issue by inserting the following below the "If Destination.Count > 1 Then Exit Sub" line:
If Not Destination.Column = 5 Then Exit Sub
The worksheet now allows me to make my multiple selections in column 5 (E), and single selections in column 6 (F).
Hi! Pay attention to which sheet code you added this string of code to. The code works only on the sheet in which it is inserted.
Hi Alexander
thanks for your comprehensive useful post. I have a problem here, I did everything same as you've mentioned here, and it works as multiple selection with removal enabled, so I save my worksheet as macro enabled, but after I close and reopen the file, it won't work as multiple selection but only single selection
Hi! Your file has macros disabled. Save the file as xlsm. Try using these recommendations: How to enable and disable macros in Excel.
Hi Alexander, Thanks for the post very useful. Can we restrict selection of entries to 3 max based on comma's. May be stop at selected 3 entries and error when adding the 4th one. Appreciate if you could help with the code to use in the above example.
Hi! As much as I'd like to help, I'm overloaded with some current projects at the moment and won't be able to take time for your task. Custom code changes are quite time-consuming.
no problem. Thank you!
Thanks, sir. It's my first time trying macro. It is very useful for my project. All Thanks to your clear tutorial and code.
Hey, is it possible to select a few items at one go from the dropdown list? For example, instead of selecting "Apples" , "Oranges", separately, is there a way to select multiple items at one go? So that Apples and Oranges will be displayed together at the same time without an extra step of selecting each item one by one. Perhaps like a checkbox before each item in the dropdown list.
Hi! Unfortunately, the dropdown list in Excel only allows you to select one value at a time.
Hello. I used the VBA code in an Excel spreadsheet to allow multiple drop-down box selections in separate lines. Instead of DelimiterType = “,” I changed it to Delimiter = vbCrLf. I saved it as a xlsm file and it worked great. I got out of the spreadsheet and saved it. When I reopened to test it again, it would not work even though the same code was there. I have deleted the code and recopied it and also saved as a different xlsm file name. Do you have any ideas on what might have happened? I’m clueless and out of things to try. Any assistance would be appreciated.
Hi! You can use the ready-made code from the example file (Selections in separate lines sheet) linked to at the end of this article.
Is it possible to create a drop down list in a blank spreadsheet without creating a table?
Hi! You can find useful information in this article: How to create drop down list in Excel: dynamic, editable, searchable.
Hi,
thanks for this, very useful.
I am getting a bug on the removal function.
With using a simple example where I have on my list Green Apples, Oranges, Apples; after selecting "Apples" again, the macro removes the first "Apples" - so it returns: Green , Oranges, Apples - which is not what I am expecting.
is there a way to fix this?
Thanks in advance,
Hello! Thank you for your comment. We have changed the macro code. Now the values are deleted correctly.
Hello First thank you - I was trying to read the comments on how to make this work for all sheets in a workbook rather then copying duplicate code onto each sheet (if I read the instructions correct)
Hello!
To run a macro on all worksheets in a workbook at once, the Workbook_SheetChange procedure is declared in the Workbook object and written in the ThisWorkbook code window. You can find the ThisWorkbook object in the VBAProject window below the worksheet list. Click on it and in the opened window add the code of the macro you need. You will need to add an additional parameter ByVal Sh As Object to the procedure.
For example, instead of
Sub Workbook_SheetChange(ByVal Destination As Range)
write
Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Destination As Range)
I would like to use the "Multi-selection dropdown with item removal" but also allow for a write in on one option.
For example: Location: Location A, Location B, Location C, Other Location:
and the responder could click: "Location A" and "Other Location:", then go into the write in bar and type in "Garden" after "Other Location:"
When I turn off the error alert in Data Validation I am able to do this but then the options start to duplicate themselves in the field: "Location A, Other Location:, Location A, Other Location: Garden"
Thank you for your assistance
Hi! The macro assumes that all values in the cell will be entered from the drop-down list. When you are correcting a cell manually, all of its content is considered as a new value and added to the existing text in the cell. The result is duplication.
If you have "Location A, Other Location:" written in a cell and you want to add "Garden". When editing the cell, delete all text, type "Garden", and press Enter. You will get "Location A, Other Location:,Garden".
How do I adjust this code to work, in a single column instead of in multiple data validation lists?
Hi! I kindly ask you to take a closer look at the following paragraph of the article above: Multi-select dropdown for specific columns, rows, cells
This code would prove to be very useful for me, but for some reason doesn't work for me? I downloaded the example workbook, but unfortunately all the drop downs just revert to normal - only allow single selection as per the list validation.
I am guessing there is a setting in my excel that needs correcting or perhaps the version i am using isn't compatible?
Any advice would be appreciated.
Hi! If I understand your task correctly, the following tutorial should help: How to enable and disable macros in Excel.
Great solution Alexander. Very useful. Well done !