How to Show or Hide Excel Rows Based on Multiple Drop-Down Selections
Question details
The user wants to automatically show or hide specific rows in a spreadsheet based on multiple selections made in a drop-down list cell.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating an interactive spreadsheet where selecting multiple items in a single drop-down cell dynamically filters or adjusts the visible rows to match the selected items.
- Observed behavior
- Specific rows need to dynamically update their hidden property whenever the multi-select drop-down is modified, while preserving the previously selected values in the cell.
Ensure that your workbook is saved as an Excel Macro-Enabled Workbook (.xlsm) and that you have enabled macros in your Trust Center settings.
Use a Worksheet_Change VBA Event
Apply a VBA script to automatically handle multiple selections in a drop-down and toggle row visibility based on the cell's content.
This solution uses the Worksheet_Change event triggered whenever your target cell (e.g., cell B12) is modified. It temporarily disables screen updating and application events to prevent infinite loops and performance issues.
The code first preserves multiple selections separated by commas within the cell, and then loops through the target rows (e.g., rows 16 to 23) to hide or show them depending on whether the corresponding claim text appears in the drop-down cell.
Press 'Alt + F11' in your Excel workbook to open the Visual Basic for Applications (VBA) editor.
In the Project Explorer pane on the left side of the editor, double-click the name of the worksheet containing your drop-down list (e.g., Sheet1).
Copy and paste your Worksheet_Change script into the code window. Ensure the code references your specific drop-down cell (like Range("B12")) and uses an appropriate For loop to set the .EntireRow.Hidden property for your target rows.
Close the VBA editor, save the file as a Macro-Enabled Workbook (.xlsm), and select multiple items in your target cell to verify that the correct rows are dynamically hidden or displayed.

Automate Spreadsheets Easily with WPS Office
WPS Office provides robust support for VBA and macros, allowing you to run complex automated scripts like showing and hiding rows based on drop-down selections exactly as you would in Microsoft Excel.
- 1. Download and Install: Download WPS Office for free from the official website and install it on your device.
- 2. Open Your Macro Workbook: Launch WPS Spreadsheets and open your .xlsm file containing the drop-down list.
- 3. Enable Macros: If prompted by the security warning at the top of the sheet, click 'Enable Macros' to allow the VBA scripts to run.
- 4. Run Your Automation: Make your selections in the drop-down cell and watch the rows hide or show automatically.

Frequently Asked Questions
Why is my Worksheet_Change event causing Excel to crash or freeze?
If you change a cell value within a Worksheet_Change event, it can re-trigger the event itself, causing an infinite loop. Always use 'Application.EnableEvents = False' before modifying cells in your VBA script, and set it back to 'True' right before the script ends.
Can I apply this VBA script to multiple drop-down cells at once?
Yes, you can modify the 'Intersect' function in the VBA code to check for multiple target cells by changing the range parameter (e.g., 'Range("B12, C12")') instead of checking just a single cell.
How do I create a multi-select drop-down list without using VBA?
Standard Data Validation drop-down lists in Excel natively only allow single selections. To enable multiple selections in a single cell, you are required to use a VBA Worksheet_Change event to append the new selection to the existing text.
Will this VBA row-hiding code work in WPS Office?
Yes, WPS Office Spreadsheets supports VBA and macros. You can run the exact same Worksheet_Change event code in WPS to hide or show rows dynamically, provided you save the file in a macro-enabled format.




