How to Fix VBA Multi-Select Drop-Down Removal and Line Breaks in Excel
Question details
The user needs a VBA script that correctly handles multi-select data-validation drop-downs, allowing items to be removed upon re-selection and formatting each chosen item on a separate line.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating or modifying a data-validation drop-down list using VBA to allow multiple selections within a single cell.
- Observed behavior
- Adding choices to the cell works properly, but attempting to remove a previously selected item simply restores it. Additionally, the selected values need to be separated by line breaks instead of a continuous string.
Before modifying your VBA code, ensure you save a backup copy of your workbook and verify that the target cells have 'Wrap Text' enabled so line breaks render correctly.
Update the Worksheet_Change Event Code
Modify the VBA Worksheet_Change event to safely track the previous cell value, evaluate string differences, and prevent recursive loops while updating.
The removal issue occurs because selecting a previously chosen item from a validation list triggers an overwrite rather than a deletion. By utilizing Application.Undo, you can capture the previous state of the cell. Then, use VBA logic to either append the new selection with a line break (vbLf) or completely remove the existing selection from the text string.
Press Alt + F11 to open the Visual Basic for Applications Editor, then double-click the specific worksheet in the Project Explorer where your drop-down list is located.
Inside your Worksheet_Change sub, add 'Application.EnableEvents = False' before any cell modifications to stop the macro from continuously triggering itself in an endless loop.
Assign the newly selected value to a temporary variable. Then, use the 'Application.Undo' command to revert the cell to its previous state so you can store the old text string in another variable.
Use the InStr function to check if the new value is already present in the old text string. If it is present, use the Replace function to remove it. If it is not, concatenate the old string and new value using 'vbLf' (Visual Basic Line Feed) to force a line break.
Write the final computed string back into the cell's Value property. Finally, ensure you add 'Application.EnableEvents = True' at the very end of your script to re-enable normal Excel event tracking.

Run VBA Multi-Select Macros Smoothly in WPS Spreadsheet
WPS Spreadsheet provides robust native support for VBA macros, allowing you to seamlessly run, build, and troubleshoot complex multi-select drop-downs. Enjoy a highly compatible and lightweight environment for all your advanced spreadsheet data tasks.
- 1. Open Your Macro-Enabled File: Launch WPS Spreadsheet and open your existing .xlsm file containing the data validation.
- 2. Access the Developer Tab: Navigate to the Developer tab on the top ribbon and click on 'VB Editor' to view your code.
- 3. Implement the Fix: Paste the updated Worksheet_Change logic using vbLf and Application.Undo exactly as you would in Microsoft Excel.
- 4. Save and Test: Save your workbook, ensure macros are enabled, and test the multi-select drop-down directly in the spreadsheet grid.

Frequently Asked Questions
Why does my Excel freeze when using a VBA drop-down script?
This usually happens due to an infinite loop. When your VBA script changes the cell value, it triggers the Worksheet_Change event again. You must wrap your cell-updating code between 'Application.EnableEvents = False' and 'Application.EnableEvents = True' to prevent this loop.
How do I force line breaks in an Excel cell using VBA?
In VBA, you can use the constant 'vbLf' (which stands for Visual Basic Line Feed) to insert a line break within a text string. For the line break to visually render in the spreadsheet, the target cell must also have the 'Wrap Text' format applied from the Home tab.
Does the Application.Undo command clear my clipboard?
Yes, using Application.Undo within a VBA macro typically clears the system clipboard. If your workflow relies heavily on copying and pasting, you may need to implement a workaround to restore clipboard contents or avoid triggering the macro during paste operations.




