How To Create Drop Down List With Multiple Selections Or Values In ...
Có thể bạn quan tâm
Using VBA Code
To allow multiple selections in a drop-down list, you can use "Visual Basic for Applications" (VBA) in Excel. The script can modify the behavior of a drop-down list to make it a multiple-choice list. Please do as follows.
Step 1: Open the Sheet (Code) editor
- Open the worksheet that contains the drop-down list for which you want to enable multiple selection.
- Right click the sheet tab and select "View Code" from the context menu.

Step 2: Use VBA code
Now copy the following VBA code and paste it to the opening sheet (Code) window.
VBA code: Enable multiple selections in Excel drop-down list.
Private Sub Worksheet_Change(ByVal Target As Range) 'Updated by Extendoffice 20240118 Dim xRng As Range Dim xValue1 As String Dim xValue2 As String Dim delimiter As String Dim TargetRange As Range Set TargetRange = Me.UsedRange ' Users can change target range here delimiter = ", " ' Users can change the delimiter here If Target.Count > 1 Or Intersect(Target, TargetRange) Is Nothing Then Exit Sub On Error Resume Next Set xRng = TargetRange.SpecialCells(xlCellTypeAllValidation) If xRng Is Nothing Then Exit Sub Application.EnableEvents = False xValue2 = Target.Value Application.Undo xValue1 = Target.Value Target.Value = xValue2 If xValue1 <> "" And xValue2 <> "" Then If Not (xValue1 = xValue2 Or _ InStr(1, xValue1, delimiter & xValue2) > 0 Or _ InStr(1, xValue1, xValue2 & delimiter) > 0) Then Target.Value = xValue1 & delimiter & xValue2 Else Target.Value = xValue1 End If End If Application.EnableEvents = True On Error GoTo 0 End Sub
Result
When you return to the worksheet, the drop-down list will enable you to choose multiple options, see the demo below:

- Applies to all data validation drop-down lists in the current worksheet, both existing and those created in the future.
- Prevents you from picking the same item more than once in each drop-down list.
- Uses comma as the separator for the selected items. To use other delimiters, please view this section to change the separator.
Từ khóa » Visual Basic Excel Drop Down List
-
Run A Macro From A Drop Down List [VBA] - Get Digital Help
-
Data Validation Drop Down List With VBA In Excel (7 Applications)
-
Code Or Program A Data Validation List - VBA Code Examples
-
Creating A Drop-down List In Excel Using Tools Or Macros
-
Excel VBA Drop Down Lists Using Data Validation
-
How To Make Drop Down Lists From A Macro In Excel - YouTube
-
Add A Drop Down Menu To A Cell In Excel - Data Validation Macro
-
Excel Drop Down Lists - Add New Items - Contextures
-
DropDown Method Example - Microsoft Docs
-
How To Create A Drop Down List In Excel (the Only Guide You Need)
-
How To Get Excel Drop Down List Source In Vba - Stack Overflow
-
Searchable Drop Down List Excel Vba - Xây Nhà
-
How Do You Get An Excel Drop Down List Source In VBA? - Quora
-
Combo Box In Excel VBA (In Easy Steps)
