Formatting Issues

Apply Conditional Table Cell Shading During a Word Mail Merge

Jason MillerJason Miller Nov 13, 2026 869 views

Question details

The user needs mail merge table cells to be shaded automatically based on numeric values, with red for values below zero, green for values of at least three, yellow for other numeric values, and white for nonnumeric values, without running a macro manually after each merge.

Apply Conditional Table Cell Shading During a Word Mail Merge
Product
Microsoft Word
Device & OS
not provided
Scenario
A Word mail merge document contains a table that requires conditional cell shading according to numeric thresholds in a data source.
Observed behavior
A post-merge macro applies the shading correctly when run manually, but the formatting does not apply automatically to generated documents.
Before you start

Confirm that the data source column used for the shading rule contains numeric values, not text-formatted numbers, and that the mail merge main document has a stable table location that the routine can inspect.

Solution 1Recommended

Use the Merge Tools Add-in or Chart Merge to Apply Shading During the Merge

Recommended when you need the formatting to be written automatically to each merged document instead of running a separate macro pass after the merge.

The Merge Tools add-in or a customized Chart Merge procedure can pass each merged output document to a VBA routine while the merge is being processed. This allows table cell shading to be applied before the generated document is finalized.

1
Open Mail Merge Tools in Word

In Microsoft Word, open the Mailings tab and confirm that the Merge Tools add-in is available in the Add-ins group. If it is not visible, go to File > Options > Add-ins, select COM Add-ins from the Manage list, and click Go to enable it.

2
Start the merge through the add-in

In the Merge Tools add-in, choose the merge option or customized Chart Merge procedure that passes the output document to a VBA routine during the merge.

3
Apply the conditional shading rules

Inside the VBA routine, access the first table in the output document, inspect each cell value, and set the cell shading to red for values below zero, green for values of at least three, yellow for other numeric values, and white for nonnumeric values.

4
Generate and verify the merged document

Finish the mail merge and open one generated document to confirm that table cells show the expected shading automatically without a manual macro run.

Use the Merge Tools Add-in or Chart Merge to Apply Shading During the Merge
Shading applies during merge: When the add-in procedure is configured correctly, the conditional shading is written to each output document as part of the merge workflow.
Free Microsoft Office alternative

Use WPS Writer for Everyday Mail Merge and Table Formatting

WPS Office provides WPS Writer, a free, lightweight alternative to Microsoft Word. It opens and saves .docx files with high compatibility, includes standard mail merge tools for letters and labels, and offers familiar table shading and formatting options, making it easy to move from Word without losing everyday formatting.

Retains common table cell shading and layout in Word mail merge documentsOpens and saves .docx files with Microsoft Office format compatibilityFree mail merge tools for letters, labels, and envelopesFamiliar ribbon interface that reduces migration effort from Microsoft WordLightweight and responsive even on older PCs
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Word mail merge macro only shade table cells when I run it manually?

Standard Word mail merge does not automatically run post-merge VBA routines. The shading can be applied automatically only when the merge is routed through an add-in such as Merge Tools or a customized Chart Merge procedure that invokes the VBA routine during output generation.

What shading rule should I use for the numeric thresholds?

Set red shading for values below zero, green shading for values of at least three, yellow shading for all other numeric values, and white shading for nonnumeric values.

Can I use WPS Writer to apply the same conditional shading during mail merge?

WPS Writer supports standard mail merge and table formatting, but it does not provide the Word-specific Merge Tools add-in. You can open the merged .docx in WPS Writer and use its table formatting tools for manual or semi-automatic adjustments.

What should I check if the VBA routine does not shade the correct cells?

Verify that the table index in the code matches the target table in the merged document and that the cell values are numeric or can be converted to numbers for comparison, because text-formatted numbers may be treated as nonnumeric.