logo
search
Template Issues

How to Remove Empty Rows from a Word Mail Merge Table

Maira MehtabMaira Mehtab Sep 22, 2026 869 views

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 you start

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.

Solution 1Recommended

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.

1
Access Mail Merge Rules

Open your mail merge document, place your cursor where the table row data begins, and navigate to the Mailings tab.

2
Set Up the Conditional Logic

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.

3
Enable Blank Line Suppression

Open your mail merge options or properties and verify that 'Suppress blank lines when data fields are empty' is checked.

4
Toggle Field Codes for Advanced Row Hiding

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.

Best Practice: Testing your conditional logic with a small subset of your data (e.g., one fully populated record and one partially empty record) will save you time before running a massive mail merge.
WPS Writer Feature

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. 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. 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. 3. Preview the Output: Click 'View Merged Data' to check how your table handles records with fewer than fifteen units.
  4. 4. Complete the Merge: Click 'Merge to New Document' to generate a clean, gap-free file ready for printing or distribution.
Easily apply rules to suppress empty rows or blank lines100% compatible with Microsoft Word documents and Excel data sourcesIntuitive ribbon interface for managing complex data listsFree to use for everyday document generation
microsoft office alternative - wps office

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.