How to Make Multiple Selections in a Drop Down List in Excel Show
FREE EXCEL TIPS EBOOK - Click here to get your copy One of my colleagues asked me if it is possible to make multiple selections in adrop-down list in Excel. When you create a drop-down list, you can only make one selection. If you select another item, the first one is replaced with the new selection. He wanted to make multiple selections from the same drop down in such a way that the selections get added to the already present value in the cell. Something as shown below in the pic: If you create multiple, linked drop-down lists, you can use the item selected from the drop-down list in B1 to drive the contents of the drop-down list in B2. Let’s take a look at how you can set this up. Also, feel free to download our example Excel sheet with the example below. Working with your drop-down list
After you create your drop-down list, make sure it works the way you want. For example, you might want to check to see if Change the column width and row height to show all your entries. If the list of entries for your drop-down list is on another worksheet and you want to prevent users from seeing it or making changes, consider hiding and protecting that worksheet. For more information about how to protect a worksheet, see Lock cells to protect them. If you decide you want to change the options in your drop-down list, see Add or remove items from a drop-down list. To delete a drop-down list, see Remove a drop-down list. Download our examples
You can download an example workbook with multiple data validation examples like the one in this article. You can follow along, or create your own data validation scenarios. Download Excel data validation examples.
Data entry is quicker and more accurate when you restrict values in a cell to choices from a drop-down list.
Start by making a list of valid entries on a sheet, and sort or rearrange the entries so that they appear in the order you want. Then you can use the entries as the source for your drop-down list of data. If the list is not large, you can easily refer to it and type the entries directly into the data validation tool.
See alsoApply data validation to cells
After you create your drop-down list, make sure it works the way you want. For example, you might want to check to see if Change the column width and row height to show all your entries. If you decide you want to change the options in your drop-down list, see Add or remove items from a drop-down list. To delete a drop-down list, see Remove a drop-down list. Download Practice WorkbookHow to Create Drop Down List in Excel with Multiple Selections.xlsm Steps to Create Drop-Down List in Excel with Multiple SelectionsHere we’ve got a data set with the Names of some books in a bookshop called Martin Bookstore. Our objective today is to create a drop-down list based on this data set that takes multiple selections. We will accomplish this in two steps. Step 1: Creating a Drop-Down List by Data Validation Step 2: Enabling that List to Accept Multiple Selections by VBA Code Step 1: Creating a Drop-Down List by Data Validation
Similar Readings:
Step 2: Enabling the Drop-Down List to Accept Multiple Selection by VBA CodeNow we’ve created a drop-down list. But up till now, it accepts a single selection. We want it to accept multiple selections.
Case 1: VBA Code for Multiple Selection with RepetitionIf you want multiple selections with repetition, enter the following code: Code: Private Sub Worksheet_Change(ByVal Target As Range) Dim Oldvalue As String Dim Newvalue As String On Error GoTo Exitsub If Target.Address = "$D$4" Then If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then GoTo Exitsub Else: If Target.Value = "" Then GoTo Exitsub Else Application.EnableEvents = False Newvalue = Target.Value Application.Undo Oldvalue = Target.Value If Oldvalue = "" Then Target.Value = Newvalue Else Target.Value = Oldvalue & ", " & Newvalue End If End If End If Application.EnableEvents = True Exitsub: Application.EnableEvents = True End SubNote: Here in the 5th line of the code (If Target.Address = "$D$4" Then), “$D$4” is the cell where I am entering the list. You use your one. If you want to enter the list in multiple cells, then repeat the line for multiple cells using an or operator. For example, if you want to enter the list in cells D4, F4, and H4, use: If Target.Address = "$D$4" or Target.Address = "$F$4" or Target.Address = "$H$4" Then Case 2: VBA Code for Multiple Selection without RepetitionAnd if you don’t want repetition, use this code instead. Code: Private Sub Worksheet_Change(ByVal Target As Range) Dim Oldvalue As String Dim Newvalue As String Application.EnableEvents = True On Error GoTo Exitsub If Target.Address = "$D$4" Then If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then GoTo Exitsub Else: If Target.Value = "" Then GoTo Exitsub Else Application.EnableEvents = False Newvalue = Target.Value Application.Undo Oldvalue = Target.Value If Oldvalue = "" Then Target.Value = Newvalue Else If InStr(1, Oldvalue, Newvalue) = 0 Then Target.Value = Oldvalue & ", " & Newvalue Else: Target.Value = Oldvalue End If End If End If End If Application.EnableEvents = True Exitsub: Application.EnableEvents = True End SubNote: Here in the 6th line of the code (If Target.Address = "$D$4" Then), “$D$4” is the cell where I am entering the list. You use your one. If you want to enter the list in multiple cells, then repeat the line for multiple cells using an or operator. For example, if you want to enter the list in cells D4, F4, and H4, use: If Target.Address = "$D$4" or Target.Address = "$F$4" or Target.Address = "$H$4" Then After entering any of the above codes, save the file as an Excel Macro-Enabled Workbook (*.xlsm). Now come back to your worksheet and go to the drop-down list you created earlier. You will be able to make multiple selections from the list now, separated by commas (,). |