By default, Excel data validation only allows users to select 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. Continue reading
by Alexander Trifuntov, updated on
By default, Excel data validation only allows users to select 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. Continue reading
Comments page 6. Total comments: 658
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 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".
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.
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 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.
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.
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.
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.
It's almost like I need to allow for the error and stop the duplication of the new value. Does that make sense?
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?
This question has been asked many times in the comments. The answer is "No".
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.
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.
Hi! If I understand your task correctly, the following tutorial should help: Create drop down list in Excel: static, dynamic, editable, searchable.
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, I tried making the Multi-selection dropdown with item removal and it works only for some items on my list. It looks like it doesn't work for items with '&' in it. Is there a way to fix that?
Hi! Unfortunately, I have not been able to reproduce your problem. The '&' symbol has no effect on the workings of the code.
Hi! I need to do the multiple drop down in multiple columns. I have tried adding another range line
If Intersect(ActiveCell, Range("D4:D79")) Is Nothing Or Intersect(Destination, rngDropdown) Is Nothing Then
'do nothing
or adding another section of code (copying the code again but changing the range it affects) but this does not work. Is there a way to do more than one in an excel sheet?
Hi! Use the Union function to check whether the active cell is in one of the ranges.
For example:
If Intersect(ActiveCell, Union(Range("C3:D10"), Range("C15:D17"))) Is Nothing Or Intersect(Destination, rngDropdown) Is Nothing Then
I hope it’ll be helpful.
Thank you! This solved the issue
Hello Alexander, I hope you are well. Great tutorial, thank you for sharing.
Can you show a modified version of the code to only allow multiple selection for a selection of dropdowns over a certain cell range please?
Grateful for your help with this - thank you.
Kind regards,
Richard.
Hi! Please read the following paragraph in the article above very carefully: Multi-select dropdown for specific columns, rows, cells and ranges.
Thank you for your quick reply Alexander, I appreciate that. Clearly I need to get my eyes tested lol
Is there a way to add the code over every sheet in a workbook without having to do each sheet individually, so as you add sheets, they already have the code?
Hi! Unfortunately, Excel doesn't work that way.
Codes are working fine but for protected sheet I am able to make a single entry only. Multiple entry is not possible with it when sheets are protected. I have applied your code for password protected sheet but it is not working.
Hi! You can read all the possible solutions to your problem in the comments below.
The multiselect with removal does not remove the first entry. It will remove all other entries but does not return to blank.
Hi! You can clear a cell with the Del key.
Hello, Is there a way to ensure your drop down list is always in alphabetical order and not click order?
I sort the source to be A-Z, then drop down list appear in A-Z order as well.
Hi! A drop-down list creates a text string in a cell. You need a special macro to sort the words in this text string.
How do I make a field on the drop down where they can enter text as and "other" option?
Hi! You can edit text in a cell with a drop-down list in the same way as a regular cell with text. You can also create a Editable drop down list.
I'm trying to use your code to enable multi-selection functionality in protected sheet, but I don't know where to put this code in the VBA (I'm also using your code for "Multi-selection dropdown with item removal") Can you please provide me with the exact location where this code should be placed?
Hi! This has been discussed many times in the comments of this article. Add the code after the "Multiple selection drop down with item removal" code or whatever code you use.
Thanks so much for your quick response! I went through the old comment around this topic but doesn't seem like they received any solutions. I did try put the code for "Enable multi-selection functionality in protected sheet" after my main code "Multi-selection dropdown with item removal". it's still doesn't work. It's giving me single select of the latest one I selected. Please see below my code and any help will be greatly appreciated.
Option Explicit
Private Sub Worksheet_Change(ByVal Destination As Range)
Dim rngDropdown As Range
Dim oldValue As String
Dim newValue As String
Dim DelimiterType As String
DelimiterType = vbCrLf
Dim DelimiterCount As Integer
Dim TargetType As Integer
Dim i As Integer
Dim arr() As String
If Destination.Count > 1 Then Exit Sub
On Error Resume Next
Set rngDropdown = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitError
If rngDropdown Is Nothing Then GoTo exitError
If Destination.Column 8 And Destination.Column 10 And Destination.Column 12 And Destination.Column 14 And Destination.Column 16 And Destination.Column 18 And Destination.Column 20 And Destination.Column 22 And Destination.Column 24 And Destination.Column 26 Then GoTo exitError
TargetType = 0
TargetType = Destination.Validation.Type
If TargetType = 3 Then ' is validation type is "list"
Application.ScreenUpdating = False
Application.EnableEvents = False
newValue = Destination.Value
Application.Undo
oldValue = Destination.Value
Destination.Value = newValue
If oldValue "" Then
If newValue "" Then
If oldValue = newValue Or oldValue = newValue & Replace(DelimiterType, " ", "") Or oldValue = newValue & DelimiterType Then ' leave the value if there is only one in the list
oldValue = Replace(oldValue, DelimiterType, "")
oldValue = Replace(oldValue, Replace(DelimiterType, " ", ""), "")
Destination.Value = oldValue
ElseIf InStr(1, oldValue, DelimiterType & newValue) Or InStr(1, oldValue, newValue & DelimiterType) Or InStr(1, oldValue, DelimiterType & newValue & DelimiterType) Then
arr = Split(oldValue, DelimiterType)
If Not IsError(Application.Match(newValue, arr, 0)) = 0 Then
Destination.Value = oldValue & DelimiterType & newValue
Else:
Destination.Value = ""
For i = 0 To UBound(arr)
If arr(i) newValue Then
Destination.Value = Destination.Value & arr(i) & DelimiterType
End If
Next i
Destination.Value = Left(Destination.Value, Len(Destination.Value) - Len(DelimiterType))
End If
ElseIf InStr(1, oldValue, newValue & Replace(DelimiterType, " ", "")) Then
oldValue = Replace(oldValue, newValue, "")
Destination.Value = oldValue
Else
Destination.Value = oldValue & DelimiterType & newValue
End If
Destination.Value = Replace(Destination.Value, Replace(DelimiterType, " ", "") & Replace(DelimiterType, " ", ""), Replace(DelimiterType, " ", "")) ' remove extra commas and spaces
Destination.Value = Replace(Destination.Value, DelimiterType & Replace(DelimiterType, " ", ""), Replace(DelimiterType, " ", ""))
If Destination.Value "" Then
If Right(Destination.Value, 2) = DelimiterType Then ' remove delimiter at the end
Destination.Value = Left(Destination.Value, Len(Destination.Value) - 2)
End If
End If
If InStr(1, Destination.Value, DelimiterType) = 1 Then ' remove delimiter as first characters
Destination.Value = Replace(Destination.Value, DelimiterType, "", 1, 1)
End If
If InStr(1, Destination.Value, Replace(DelimiterType, " ", "")) = 1 Then
Destination.Value = Replace(Destination.Value, Replace(DelimiterType, " ", ""), "", 1, 1)
End If
DelimiterCount = 0
For i = 1 To Len(Destination.Value)
If InStr(i, Destination.Value, Replace(DelimiterType, " ", "")) Then
DelimiterCount = DelimiterCount + 1
End If
Next i
If DelimiterCount = 1 Then ' remove delimiter if last character
Destination.Value = Replace(Destination.Value, DelimiterType, "")
Destination.Value = Replace(Destination.Value, Replace(DelimiterType, " ", ""), "")
End If
End If
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
exitError:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect Password:="DVonly"
On Error GoTo exitError2
If Target.Validation.Type = 3 Then
Else
ActiveSheet.Protect Password:="DVonly"
End If
Done:
Exit Sub
exitError2:
ActiveSheet.Protect Password:="DVonly"
End Sub
Hi! There are no errors in the code. But I can't look in your workbook and your Excel to find the cause of the problem. Try installing the code in a new workbook or downloading the sample file from the link at the end of the article.
I created a brand new file and copied the Multi-selection dropdown with item removal code and added If Not Destination.Column = 4 Then GoTo exitError before the "TargetType = 0" line. This worked as expected. I added the How to enable multi-selection functionality in protected sheet code at the end. The new file has "password" as the password. When I click on the drop down, the file changes to the sheet with the Table for the drop down and changes the Table to a list, not adding the second selection to the drop down.
Hi! Unfortunately, I did not have a replication of your problem in my workbook. Please note that the code to enable the multi-select functionality in the protected sheet should be added at the end of your code, after the main code.
Is there any way to apply multiple dropdown feature on web excel ? Like on "OneDrive"
Hi! We have answered this question many times before. For example, here.
An honestly wonderful bit of code you put together. I am curious if it is possible to limit the selection to a particular range? I have tried adding each cell of the range, but the list gets excessively long (B11:C50). Neither column nor row limitation work perfectly as it negatively impacts other parts of the worksheet.
Hopefully I am overlooking something simple. Regardless, thanks for your VBA (Very Beautiful Algorithm).
Hello! Replace the following line of code to restrict the execution of the multiple selections macro to a range of cells
If Intersect(Destination, rngDropdown) Is Nothing Then
на
If Intersect(ActiveCell, Range("B11:C50")) Is Nothing Or Intersect(Destination, rngDropdown) Is Nothing Then
I hope my advice will help you solve your task.
Hi, this is great.
I used your code for Multi-selection dropdown with item removal for a specific cell option and got it working as I wanted. However, for some reason, it broke some of the macros I had in that worksheet. All the sudden my macros started giving me "variable not defined error" in multiple instances. Deleting your code fixed the issue.
I have your code at the very top in Sheet1 followed by over 20 macros triggered by buttons
After spending some time digging for answers the problem relies in the fact that your code requires the "option explicit" line. This forces me to define every single variable in my macros.
is there any workaround other than defining every single variable in my >20 macros?
Any suggestion is welcome.
Thanks
Hi! If the "option explicit" option appears in the module, you must explicitly declare all variables using Dim, Private, Public, ReDim, or Static instructions. You can try removing this option, but I don't guarantee the code will work correctly.
Ok found a workaround (i think). i have to cut and paste the macros from the buttons into separate modules and then assign those modules back to the buttons.
Cheers
Is there a way to show the dropdown symbol in excel cell using VBA (for multi selection dropdown handled thru VBA code)?
Hi! Excel has a special method of identification for cells with a drop-down list. The code for multiple selections works in all cells with a drop-down list. Unless you specify a specific range. You could try writing VBA code to get what you want, but we don't provide that help on this blog.
Thanks for the instructions! Now I want to send this Excel file to colleagues. Tried it, and from some email addresses it bounced back. I am presuming because of the macros in the Excel file which could be seen as a security risk. I tried creating a xlsx, but it loses the multiselection functionality. Is there any way to preserve the multiselection functionality in a document format that won't be perceived as a security risk?
Hi! Unfortunately, there is no other option in Excel. You can try sending the file as an archive. Maybe this article will be helpful: How to enable and disable macros in Excel.
Brilliant work!
(One other tutorial I looked at required specifying the call with the drop-down. Ugh.)
Thank you, Alexander.
-- Jon
Thanks for this tutorial. It was very helpful.
I have created a pivot a table and I will like my multi-selections to appear individually as column headers. Can this be achieved?
Hi! Multiple selection macros only work for the drop down lists you have created.
I simply cannot discern where, within the code that appears in the "VBA code to select multiple items in dropdown list" table, that the suggested code for introducing column flexibility (below) should be inserted! Please advise. Thanks.
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
Hi! Pay attention above to the beginning of paragraph: How to create multi-select dropdown for specific columns, rows, cells. It says where to insert this code.
Hello, thank you for this useful website.
I have questions please,
I tried making a drop down with multiple selections for my data, but when I insert the formula =INDIRECT("Table1[Items]")
I get an error message saying (the source currently evaluate to error !)
I don't why?
Another question: I cannot see from where the name "Table1" in the above formula came?
Thank you
Hi! If I understand your task correctly, this article may be helpful: Create drop-down from Excel table.
Hi,
Thanks for the information. Its really help. I'm trying to use the code in protected sheet but fail to do so.
Questions:- How im going to make the code valid for more then one table list in one sheet. Cause i tried many times but its not gonna work on your code above. Please help me regarding this. i have use these code fo yours: Multi-selection dropdown with item removal & Enable multi-selection functionality in protected sheet at my Excell. Thanks in advance.
Hi! Unfortunately, your problem is not very clear. The code works for all dropdown lists on the sheet. If you want to limit its use, I recommend you to read carefully the paragraph: Multi-select dropdown for specific columns, rows, cells. Or explain it in more detail.
Thanks for your feedback. I already follow step by step, to enable the dropdown list, that can be use and pick multiple and its work perfectly using this code: Multi-selection dropdown with item removal. Unfortunately, after I implement the code that can Enable multi-selection functionality in protected sheet at my Excell, the dropdown list can't be select as before. it only pick one instead of more than one items in one cell. if i delete this code : Enable multi-selection functionality in protected sheet at my Excell, its back to normal. Cause i need to protect the sheet at several cell and remain unprotected at several cell to user for key in the input. If you have other solution on this issues please help. Thanks in advance. Really appreciate.
Hi! The code you are given works with a protected worksheet. This method of protection is described here: How to protect Excel sheet. This protects the entire sheet, not individual cells.
There is also a lot of discussion of this problem in the comments below. For example, here.
Thanks for reply. As i understand on your comment, it is valid for the different dropdown list (one or more set of validation) or it's only valid for one list(table) of dropdown only in one worksheet. And for your information, i already go through the other comment but there is no solid answer for the issue yet.
If you look carefully, you'll read in the second paragraph of the article: "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".
In the example file, you can see how multiple selections works for 5 dropdown lists on one sheet.
added input issue:-
- I have more than one list of dropdown in one sheet. I already try add the other list of dropdown into your practice example excel and its won't work if I add the Enable multi-selection functionality in protected sheet at my Excell, So the conclusion, its fail to pick more than one items, if the sheet content more than one dropdown list in protected sheet.
A worksheet can have any number of dropdown lists with multi-selection functionality. I cannot see what you are doing. Try to carefully follow the recommendations from the article above.
I am not an expert in excel. Your VBA code helped me a lot. But still am facing problem with the "protection".
Can u explain where to insert the protection code along with the existing code.
I did copy, paste with the existing code, but it doesn't work. do you have some pictures or videos to share.
Thank you.
Hi! You can see a sample code in this paragraph above: How to enable multi-selection functionality in protected sheet.
Hi,
I've tried to the copy paste of the code that was recommended in the paragraph above, but it didn't work. I saw other people had the some issue. Could you please give an example of the complete code including both the Multi Selection functionality as well as the code to Unprotect and protect so we could evaluate what we're not doing properly?
Or even include this type of example in the excel spreadsheet you provided as an example?
Thank you in advance
Hi!
1. Add the code you need to the worksheet. For example, Multi-select drop down without duplicates.
2. AFTER THIS CODE, add the code for working on the protected sheet from the paragraph: Enable multi-selection functionality in protected sheet.
3. That's all.
Hi,
Thanks for the code it works great. I would like to have it applied to a range of cells that are in a table like all the ones that are in "Column1" but nowhere else, how could I do that please?
Thanks in advance!
Hi! I kindly ask you to take a closer look at the following paragraph of the article above: How to create multi-select dropdown for specific columns, rows, cells.
Thanks for the article, it was very helpful.
How would I adjust the code for multi-selection dropdown with item removal to display the selected options in alphabetical order?
Ideally would want to have the same result if <1 option is selected, regardless of selection order.
Hi! To sort text in a cell alphabetically, you need a separate macro. Unfortunately, we do not plan to do this.
The multi-select code with and without removal does not work. I have read and implemented the instructions 6 times and only one item can be selected. I have saved the sheet as a macro enabled excel file. I have created the list using the table and the "INDIRECT" line of code. I have created the developer tab and added the VBA code exactly as it is shown in the article. But only one item can be selected.
Hi! Unfortunately this information is not enough to understand the cause of the problem. I can't see how you added the code to your worksheet. Try using the sample file linked at the end of the article.
You may want to add a step to your list. I had to close out of the spreadsheet entirely and re-open it for the macro to be enabled.
This code is a tremendous help. Thanks!
Worked perfectly, thanks!
So helpful!!! Thank you!
Hello,
Thanks so much for this code - it's great! One challenge I have though is that when you use the code to enable removal of previously selected items it doesn't quite work for me. Let's say I have 2 items that can be selected - QWE; RTY and am using the custom delimiter: " | "
If I select QWE, then RTY, they are now both added to the list like this : "QWE | RTY"
If I re-select RTY, it is now removed from the list like this: "QWE"
If I re-select QWE a second time, it is added to the list a second time, NOT removed, like this "QWE | QWE"
If I re-select QWE again a third time, they are both now removed and there is nothing left in the list.
The case where an item is added twice only happens when you try and remove the first item in the list. My best guess is that this because the first instance automatically doesn't have a de-limiter, so perhaps the code for removal is looking for a de-limiter, doesn't see it, then s then adds the item again with one? Then when you select a third time, it picks them both up due to the de-limiter?
I'm not sure, I'm not great with code but would appreciate if you're able to provide any other advice on this. this is the only VB I have in this document.
Thanks!
Hi! We have made changes in the code. Reinstall the code Multi-selection dropdown with item removal. Thank you for your comment!
Hi,
code was working greatly, but I have now new company notebook, suddenly code stopped working. I have downloaded your practice sheet, and it does not work as well.
No errors, dropdown list allows only one selection.
Excel version: Microsoft® Excel® for Microsoft 365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit
Any suggestions ?
Hi! Maybe these articles will be helpful: How to enable and disable macros in Excel and Excel VBA macro tutorial: how to create, change, copy and delete macros.
Hi.
I understand the basics for macros to run.
OFF COURSE all macros are enabled, folders trusted.
Anyway it doesnt work. I was trying altering the code.
I deleted this section at the end and it worked for a while. Then again stopped working.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Looks to me like option explicit doesnt run properly.
Hi. On the old computer the code worked, on the new computer it does not work. Conclusion: your new computer software is the problem, not the macro code. Unfortunately, I am not able to solve this problem for you.
Hi Thank you for this code - it works but I wanted to take it a step further. I am using the code which places the selected items on a new line (so DelimiterType = vbCrLf), but I also want to add a comma to the previous line.
I have tried "DelimiterType = & ", " vbCrLf" - but this creates an issue because it allows an item to be selected twice, then after selecting that item a couple more times, only then do all instances get deleted.
Can you advise how to add a comma to the end of the previous line?
Thank you.
Gemma
Hi! Here's how to set the line separator correctly:
DelimiterType = "," & vbCrLf
Actually, I've just recopied the code and used "DelimiterType = "," & vbCrLf" and it seems to be working now.
Thank you
Gemma
Hi, thank you this code was very helpful. I am using the code which allows duplicates to be selected and I would like to count how many times each word is mentioned (including duplicates within cells). Do you know if there is a way to do this? I have tried the COUNTIF and SUMPRODUCT functions but cannot find a way to count the duplicates also - it counts a maximum of 1 per cell. Thanks.
Hi! See the answer in the previous comment.
Hi. Thanks for the comprehensive explanation. I have used the VBA successfully and created the multi selection list for all my worksheets - it works great! Once i have collected my data, is there any way to calculate/summarise how many of each selection within a drop down list have been selected. i.e. if i and counting fruit and have selected "apples" ten times (or 1000) and selected "pears" 37 times, how can i get excel to calculate that without me having to count each individual selection.
Hi! A drop-down list creates a text string in a cell. To count cells with specific text, try these instructions: How to count cells with certain text in Excel. I hope it’ll be helpful. If this is not what you wanted, please describe the problem in more detail.
Hi Alexander,
Thank you for the VBA. I am successfully using the code for the multi-select with removal and have added the part to do the selection on specific columns on one sheet. However, when I attempt to use the same code on other sheets in the same workbook (I have updated to point to the relevant columns in the new sheets) it does not work.
Is there something that I'm doing wrong or can this only be used on one sheet in a workbook? Any suggestions will be appreciated.