How to add multiple options in a cell for a list

LSTQE 0 Reputation points
2026-11-27T03:46:32.9233333+00:00

I created a spreadsheet with a drop down menu using a list.

I used a code so that I can select multiple options without repetition.

It stopped working out of nowhere and now I can only select one option. The original data that I input with multiple options is still there however nothing new can change.

I haven't changed the code or done anything different.

This is the code im using:

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 = ", "

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 Intersect(Destination, rngDropdown) Is Nothing Then

'do nothing

Else

Application.EnableEvents = False

newValue = Destination.Value

Application.Undo

oldValue = Destination.Value

Destination.Value = newValue

If oldValue <> "" Then

If newValue <> "" Then

    If oldValue = newValue Or _

        InStr(1, oldValue, DelimiterType & newValue) Or _

        InStr(1, oldValue, newValue & Replace(DelimiterType, " ", "")) Then

        Destination.Value = oldValue

            Else

        Destination.Value = oldValue & DelimiterType & newValue

    End If

End If

End If

End If

exitError:

Application.EnableEvents = True

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

Any advice is appreciated.

Developer technologies | Visual Basic for Applications
0 comments No comments

2 answers

Sort by: Most helpful
  1. AI answer

    2026-11-27T04:30:55.49+00:00

    Run Application.EnableEvents = True in the VBA Immediate window first, because the drop-down reverting to normal single-select behavior indicates that the Worksheet_Change event is not currently executing.

    Restore Excel events

    1. Press Alt+F11 to open the Visual Basic Editor.
    2. Press Ctrl+G to open the Immediate window.
    3. Enter the following and press Enter:
    Application.EnableEvents = True
    
    1. Return to Excel and select another drop-down item.

    Application.EnableEvents controls whether Excel raises events such as Worksheet_Change.^1^ Your procedure temporarily sets it to False; if execution was interrupted while debugging, Excel could have remained in that state for the current session.

    Make the event handler safer

    Replace the existing handler with the following, adjusting C2:C124 to the cells containing the drop-downs:

    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        Const SEP As String = ", "
        Dim oldValue As String, newValue As String
    
        On Error GoTo CleanUp
    
        If Target.CountLarge > 1 Then Exit Sub
        If Intersect(Target, Me.Range("C2:C124")) Is Nothing Then Exit Sub
        If Target.Validation.Type <> xlValidateList Then Exit Sub
    
        newValue = CStr(Target.Value2)
        If Len(newValue) = 0 Then Exit Sub
    
        Application.EnableEvents = False
        Application.Undo
        oldValue = CStr(Target.Value2)
    
        If Len(oldValue) = 0 Then
            Target.Value2 = newValue
        ElseIf InStr(1, SEP & oldValue & SEP, _
                     SEP & newValue & SEP, vbTextCompare) = 0 Then
            Target.Value2 = oldValue & SEP & newValue
        Else
            Target.Value2 = oldValue
        End If
    
    CleanUp:
        Application.EnableEvents = True
    End Sub
    

    Place this code in the worksheet module, not in a regular module:

    1. Right-click the relevant worksheet tab.
    2. Select View Code.
    3. Paste the code there.
    4. Save the workbook.

    A single worksheet event can manage multiple drop-down cells, and each cell retains its own selections.^2^ Worksheet_Change runs when a user changes a worksheet cell; it does not run for changes caused only by recalculation.^3^

    If it still selects only one item

    Check these conditions in order:

    • Workbook format: It must remain an Excel macro-enabled workbook (.xlsm). Saving as .xlsx removes VBA.
    • Macros blocked: If Excel displays a security warning, select Enable Content only if this is your workbook and you trust its code. Alternatively, check File → Options → Trust Center → Trust Center Settings → Macro Settings. Microsoft recommends enabling macros only for trusted files.^4^
    • Correct worksheet module: Confirm the procedure is under the sheet containing the drop-down cells, rather than Module1 or ThisWorkbook.
    • Correct range: Change C2:C124 in the replacement code to the actual drop-down range. For noncontiguous cells, use:
    If Intersect(Target, Me.Range("C2:C20,E2:E20,G5")) Is Nothing Then Exit Sub
    

    Excel data-validation lists are natively single-select; the multiple-value behavior depends entirely on the VBA event running.^5^


    References

    1. Application.EnableEvents property (Excel)
    2. In Excel, I am in need of having more than one dropdown list in a worksheet, and I must be able to make multiple selections in each one. - Microsoft Q&A
    3. Worksheet.Change event (Excel)
    4. Enable or disable macros in Microsoft 365 files | Microsoft Support
    5. How to set multiple select dropdown in Excel using C# DocumentFormat.OpenXml library? - Microsoft Q&A
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

  2. Nancy Vo (WICLOUD CORPORATION) 8,240 Reputation points Microsoft External Staff Moderator
    2026-11-27T04:15:39.0066667+00:00

    Hello @LSTQE ,

    Thanks for your question.

    Your code looks fine, and the old values are still in the cells, so the issue might not be in the code. It may be that the Worksheet_Change event no longer runs. This could happen if Application.EnableEvents was left as False after a macro stopped partway through, if macros are disabled for the file, or if the file is opened in Excel for the web, which cannot run VBA macros.

    I suggest checking these steps:

    1. Open the file in the Excel desktop app and make sure it is saved as .xlsm.
    2. If you see a yellow Security Warning bar, click Enable Content. If you see a red Security Risk bar, close the file, right-click it, select Properties, check Unblock on the General tab, then open it again.
    3. Press Alt+F11, then press Ctrl+G to open the Immediate window. Type the line below and press Enter:
    ?Application.EnableEvents
    
    1. If it shows False, type this line and press Enter:
    Application.EnableEvents = True
    
    1. Make sure the code is in the module of the sheet that has the drop-down list, for example Sheet1. It should not be in Module1.
    2. Go back to the sheet and select a new option from the list.

    You may also find these documents useful:

    Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.