Document Editing Problems

How to Dynamically Display Word Table Rows Based on a Dropdown Value

Natalie TaylorNatalie Taylor Nov 3, 2026 869 views

Question details

The user needs a way to automatically show odd-numbered rows and hide even-numbered rows when selecting 'Yes' in a dropdown list, and reverse this visibility when selecting 'No'.

How to Dynamically Show Word Table Rows Based on a Dropdown
Product
Word / WPS Writer
Device & OS
not provided
Scenario
Creating an interactive form or dynamic document where table row visibility conditionally adjusts based on user input in a dropdown menu.
Observed behavior
The visibility of specific table rows needs to toggle (hidden or visible) immediately after the user makes a selection and exits the dropdown control.
Before you start

Ensure your document is saved in a macro-enabled format (.docm), as dynamic row visibility requires VBA macros. Additionally, verify that the 'Developer' tab is enabled in your ribbon to access content controls.

Solution 1Recommended

Use VBA and Content Controls to Manage Row Visibility

Utilize a Dropdown List Content Control and the Document's Exit event in VBA to manipulate the Range.Font.Hidden property of specific table rows.

This method relies on the 'ContentControlOnExit' VBA event triggered within 'ThisDocument'. By assigning a specific title to your dropdown control, the script can detect when a user interacts with it and then iterate through the table's rows to adjust their hidden status depending on the text selected.

1
Insert the Dropdown Content Control

Navigate to the 'Developer' tab on the ribbon. Place your cursor above the 10-row table and click 'Drop-Down List Content Control'. Click 'Properties' in the Controls group, set the Title to 'TableControl', and add 'Yes' and 'No' as the dropdown list choices.

2
Access the VBA Editor

Press the 'Alt + F11' shortcut on your keyboard to open the Visual Basic for Applications (VBA) editor. In the Project Explorer panel on the left, double-click on 'ThisDocument' to open the document's code module.

3
Set Up the Exit Event Macro

From the left dropdown at the top of the code window, select 'Document'. From the right dropdown, select 'ContentControlOnExit'. This generates the event handler shell where you will place your logic.

4
Write the Visibility Logic

Inside the event, write an 'If' statement checking if 'ContentControl.Title = "TableControl"'. Inside this, check if the selected text is 'Yes'. If so, use a loop to set the even rows' 'Range.Font.Hidden = True' and odd rows to 'False'. Reverse this logic for 'No'.

5
Test the Document

Close the VBA editor. Back in the document, select an option from your dropdown list, then click anywhere outside the dropdown box to trigger the exit event and observe the table updating.

Use VBA and Content Controls to Manage Row Visibility
Macro Security and Display Settings: If the rows do not visually disappear, ensure that 'Show hidden text' is unchecked in your application's display options. Additionally, ensure macros are enabled in your Trust Center settings.
Advanced Document Formatting

Create Interactive Forms with WPS Writer

WPS Office fully supports VBA macros and advanced form controls, allowing you to build highly interactive and dynamic documents just like Microsoft Word. You can seamlessly configure dropdowns and write custom scripts to control table layouts.

  1. 1. Launch WPS Writer: Open WPS Office, create a new document, and insert your table structure.
  2. 2. Enable the Developer Tab: Navigate to the ribbon, ensure the Developer tab is active, and insert a 'Drop-Down Form Field'.
  3. 3. Apply VBA Scripts: Click the 'Macros' or 'Visual Basic' button to access the editor, paste your conditional row visibility script, and save the document.
Full compatibility with Microsoft Word macro-enabled formats (.docm)Built-in Developer tools for effortless insertion of form controlsIntegrated VBA editor to write and manage custom document logicLightweight architecture for fast document loading and script execution
microsoft office alternative - wps office

Frequently Asked Questions

Why don't the rows hide immediately after I select 'Yes' or 'No'?

The VBA macro relies on the 'ContentControlOnExit' event. This means the code executes only after you make a selection and then click your cursor somewhere outside the dropdown list control.

Can I hide table rows conditionally without using macros?

No, standard word processors do not feature built-in conditional formatting for hiding table structures based on field values. VBA scripting is required to dynamically alter the 'Hidden' font property of table rows.

How can I view the hidden rows so I can edit their content?

You can temporarily reveal all hidden content by clicking the 'Show/Hide Paragraph Marks' (¶) icon on the Home tab. Alternatively, go to the application's Options, navigate to Display settings, and check 'Hidden text'.

Will this macro function if I send the document to another user?

Yes, as long as the recipient opens the document using a desktop application that supports VBA (such as WPS Writer or Microsoft Word) and they choose to 'Enable Content' when prompted by their macro security settings.