Can you allow multiple selections in Excel drop-down list?
Show By default, you can only select one item per time from a data validation drop-down list in Excel. How to make multiple selections from the drop-down list as below screenshot shown? The methods in this article can help you solve the problem. Create drop down list with multiple selections with VBA code Create drop down list with multiple selections with VBA codeYou can apply the below VBA code to make multiple selections from the drop-down list in a worksheet in Excel. Please do as follows. 1. Open the worksheet you have set data validation drop-down list, right click on the sheet tab and select View Code from the context menu. 2. In the Microsoft Visual Basic for Applications window, copy the below VBA code into the code window. See screenshot: VBA code: drop down list with multiple selections Private Sub Worksheet_Change(ByVal Target As Range) 'Updated by Extendoffice 2019/11/13 Dim xRng As Range Dim xValue1 As String Dim xValue2 As String If Target.Count > 1 Then Exit Sub On Error Resume Next Set xRng = Cells.SpecialCells(xlCellTypeAllValidation) If xRng Is Nothing Then Exit Sub Application.EnableEvents = False If Not Application.Intersect(Target, xRng) Is Nothing Then xValue2 = Target.Value Application.Undo xValue1 = Target.Value Target.Value = xValue2 If xValue1 <> "" Then If xValue2 <> "" Then If xValue1 = xValue2 Or _ InStr(1, xValue1, ", " & xValue2) Or _ InStr(1, xValue1, xValue2 & ",") Then Target.Value = xValue1 Else Target.Value = xValue1 & ", " & xValue2 End If End If End If End If Application.EnableEvents = True End Sub3. Press the Alt + Q keys to close the Microsoft Visual Basic for Applications window. Now you can select multiple items from the drop-down list in current worksheet. Notes:
Easily create drop down list with multiple selections with an amazing toolHere highly recommended the Multi-select Drop-down List feature of Kutools for Excel for you. With this feature, you can easily select multiple items from the drop-down list in a specified range, current worksheet, current workbook or all opened workbooks as you need. Before applying Kutools for Excel, please download and install it firstly. 1. Click Kutools > Drop-down List > Multi-select Drop-down List > Settings. See screenshot: 2. In the Multi-select Drop-down List Settings dialog box, please configure as follows.
3. Please click Kutools > Drop-down List > Multi-select Drop-down List to enable the feature. Now you can select multiple items from the drop-down list in current worksheet or any scope you have specified in step 2. If you want to have a free trial ( 30-day) of this utility, please click to download it, and then go to apply the operation according above steps. Related articles:Autocomplete when typing in Excel drop down list Create drop down list from another workbook in Excel Create a searchable drop down list in Excel Auto populate other cells when selecting values in Excel drop down list More tutorial for drop down list... Excel doesn’t have any built-in feature that allows you select multiple items in a dropdown. In this guide, we're going to show you how to make multiple selections in a dropdown list in Excel. Download Workbook Preparation
The code should be in the worksheet’s editor containing the dropdown, because the code tracks changes in the cell. VBA Code to make multiple selections in a dropdown listAll you need to do is to copy and paste the following code into your file and change the cell reference of the dropdown. Private Sub Worksheet_Change(ByVal Target As Range) 'Define variables Dim ExistingValue As String Dim NewValue As String Dim Separator As String 'If an error occurs, enable events and quit the code On Error GoTo Quit 'Check if the dropdown cell is changed If Target.Address = "$F$2" Then 'If user deletes the dropdown cell's data do nothing If Target.Value = "" Then GoTo Quit 'The fun begins Application.EnableEvents = False NewValue = Target.Value Application.Undo ExistingValue = Target.Value If ExistingValue = "" Then Target.Value = NewValue Else 'Check if the dropdown item is already selected If InStr(1, ExistingValue, NewValue) = 0 Then Target.Value = ExistingValue & ", " & NewValue Else Target.Value = ExistingValue End If End If End If Quit: Application.EnableEvents = True End Sub The dropdown cell’s address is on the 9th row of the code. If you are using a named range, replace the cell address “$F$4” with Range( Check the 22nd line if you want to use another character as a separator and replace the comma with any character you want. Parsing multiple selected valuesYou can even parse the selected values to consolidate the corresponding data. Check out following example. You can find detail information about text parsing in our How to split text with formulas in Excel article. |