How to Create Drop Down list in Excel with Multiple Selections
👉How to Create Drop Down list in Excel with Multiple Selections
Certainly! Creating a multi-select drop-down list in Excel allows users to choose multiple items from a predefined list. This feature can be incredibly useful for data input and accuracy. Let’s walk through the steps to create such a drop-down list:
👉Create a Normal Drop-Down List:
First, let’s create a regular data validation list in one or more cells. We’ll use this as the basis for our multi-select drop-down.
Here’s how to do it:
- Select the cell where you want the drop-down list to appear.
- Go to the “Data” tab on the ribbon.
- Click “Data Validation” in the “Data Tools” group.
- In the “Allow” drop-down menu, select “List”.
- In the “Source” box, enter the range of cells for your list (e.g., A2:A25).
- Click “OK”.
➡️Insert VBA Code for Multiple Selections:
- Now comes the magic! We’ll use VBA (Visual Basic for Applications) to enable multiple selections.
- Insert one of the following codes at the back end of your target worksheet:
➡️Multi-select drop-down without duplicates:
Private Sub Worksheet_Change(ByVal Target As Range)
- Dim rng As Range
- Dim cell As Range
- Dim selectedItems As String
- ' Define the range for your drop-down list
- Set rng = Me.Range("D3:D7")
- If Not Intersect(Target, rng) Is Nothing Then
- For Each cell In rng
- If cell.Value = True Then
- selectedItems = selectedItems & cell.Value & ", "
- End If
- Next cell
- ' Remove trailing comma and space
- selectedItems = Left(selectedItems, Len(selectedItems) - 2)
- Target.Value = selectedItems
- End If
- End Sub
➡️Multiple selection drop-down with custom delimiter:
Private Sub Worksheet_Change(ByVal Target As Range)
- Dim rng As Range
- Dim cell As Range
- Dim selectedItems As String
- Dim delimiter As String
- ' Define the range for your drop-down list
- Set rng = Me.Range("D3:D7")
- delimiter = "; " ' Customize the delimiter as needed
- If Not Intersect(Target, rng) Is Nothing Then
- For Each cell In rng
- If cell.Value = True Then
- selectedItems = selectedItems & cell.Value & delimiter
- End If
- Next cell
- ' Remove trailing delimiter
- selectedItems = Left(selectedItems, Len(selectedItems) - Len(delimiter))
- Target.Value = selectedItems
- End If
- End Sub
➡️Multiple selections in separate lines:
Private Sub Worksheet_Change(ByVal Target As Range)
- Dim rng As Range
- Dim cell As Range
- Dim selectedItems As String
- ' Define the range for your drop-down list
- Set rng = Me.Range("D3:D7")
- If Not Intersect(Target, rng) Is Nothing Then
- For Each cell In rng
- If cell.Value = True Then
- selectedItems = selectedItems & cell.Value & vbNewLine
- End If
- Next cell
- ' Remove trailing newline
- selectedItems = Left(selectedItems, Len(selectedItems) - Len(vbNewLine))
- Target.Value = selectedItems
- End If
- End Sub
➡️Test Your Multi-Select Drop-Down:
- Save your workbook and test the drop-down list. You’ll now be able to select multiple items!
- Remember that VBA macros need to be enabled for this to work.
And there you have it! A multi-select drop-down list in Excel that allows users to choose multiple items with ease. 📊 For more details and examples, you can refer to this article1. Happy Excel-ing! 🚀

Post a Comment