How to Remove Empty Rows from a Word Mail Merge Table
Question details
The user needs to set up a mail-merge table that supports up to fifteen units but does not display blank rows or large gaps when fewer units are populated in the data source.
- Product
- Word Document
- Device & OS
- not provided
- Scenario
- Setting up a mail merge document containing a table with variable rows (up to 15) to accommodate different amounts of data per record.
- Observed behavior
- When fewer data items are present than the maximum allocated table rows, empty rows and large gaps remain visible in the generated document.
Before adjusting your mail merge template, verify that your connected data source contains truly empty cells rather than cells with hidden spaces or unprintable characters, as these can disrupt conditional rules.
Use Conditional Fields to Prevent Blank Rows
Configure your merge template to only display a row if the corresponding source data exists, effectively preventing blank rows from being created in the first place.
The most reliable method is to prevent empty rows during the merge rather than attempting to delete them afterward. By using Word's 'Rules' feature or inserting conditional field codes (IF statements), you can instruct the software to skip table rows if the linked data field is completely empty. Ensure you also enable the option to suppress blank lines within your mail merge settings.
Open your mail merge document, place your cursor where the table row data begins, and navigate to the Mailings tab.
Click on 'Rules' and select 'If...Then...Else...'. Choose the target field name, set the condition to 'is not blank', and insert your merge field into the 'Insert this text' box.
Open your mail merge options or properties and verify that 'Suppress blank lines when data fields are empty' is checked.
Press Alt+F9 to reveal your document's field codes. You can manually wrap the entire table row code inside an { IF } condition to ensure the row structure itself is hidden if no data is found.
Create Flawless Mail Merges with WPS Writer
WPS Writer provides an intuitive and powerful Mail Merge toolkit that seamlessly handles conditional formatting, ensuring your generated documents remain clean without unsightly blank table rows or gaps.
- 1. Open Data Source: Launch WPS Writer, go to the 'References' tab, click 'Mail Merge', and select 'Open Data Source' to link your spreadsheet.
- 2. Insert Fields and Rules: Use the 'Insert Merge Field' dropdown to map your data units. Utilize the 'Rules' menu to set up IF conditions that prevent blank fields from displaying.
- 3. Preview the Output: Click 'View Merged Data' to check how your table handles records with fewer than fifteen units.
- 4. Complete the Merge: Click 'Merge to New Document' to generate a clean, gap-free file ready for printing or distribution.

Frequently Asked Questions
Why are blank lines still appearing even after checking 'Suppress blank lines'?
This usually happens if there are hidden spaces, punctuation marks, or stray paragraph returns inside the cell in your data source. Word processors treat these as valid data, which prevents the row from being suppressed.
Can I use VBA macros to delete empty table rows after a mail merge?
Yes. If conditional fields are too difficult to apply to a complex table structure, you can run a custom VBA macro post-merge to iterate through the document's tables and delete any row where the cells are completely empty.
Does WPS Office support IF fields in mail merge?
Yes, WPS Writer fully supports advanced field codes, including IF statements. You can press Alt+F9 to edit field codes directly and conditionally display text or hide rows based on your data source.




