Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Conditional Processing During a Mail Merge.

Conditional Processing During a Mail Merge

by Allen Wyatt
(last updated August 4, 2018)


When using Word's mail merge feature, you are not limited to using only the actual data fields when putting together your merge document. Word also includes special fields that allow you to conditionally control how Word does the merging. These types of fields can be easily inserted by clicking on the Insert Word Field drop-down list on the Mail Merge toolbar. The three fields you can use for conditional processing are as follows:

  • If ... Then ... Else. Use this field if you want to do a comparison between a data field and a value, and then take some action based on the comparison. This field is equivalent to the construct of the same name used in many programming languages.
  • Next Record If. Use this field if you want to compare the contents of a data field to a value, and then jump to the next record if the comparison is true.
  • Skip Record If. Use this field when you want to compare the contents of a data field to a value, and then ignore the current data record if the comparison is true.

You cannot use Word's conditional mail-merge fields to compare values in any record other than the current one. It would be very nice to compare the contents of a data field in the current record with the contents of the same data field in the previous record, but Word will unfortunately not allow it.

One possible workaround to this shortcoming—if you are using an Excel worksheet as your data source—is to simply copy the controlling field (column) to another column, and then offset it by one row. Here is an example:

Item Category OldCat
Dogs 1
Cats 1 1
Birds 2 1
Pigs 3 2

As Word processes each record of the data source, the value of the OldCat data field is the same as the contents of the Category data field in the previous record. Thus, you could use a compound field such as the following to check and act upon the comparison between the fields:

{IF {MERGEFIELD Category} <> {MERGEFIELD OldCat} "first text" "second text"}

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (8176) applies to Microsoft Word 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Word here: Conditional Processing During a Mail Merge.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Automatically Adding Captions

Word can automatically add captions to various elements of your document, such as tables or figures. Here's how to ...

Discover More

Default Click and Type Paragraph Style

When you use the Click and Type feature, Word uses applies the Normal style to the paragraph created. You can specify a ...

Discover More

Printing Workbook Properties

Want to create a printed record of the properties associated with a workbook? There is no easy way to do it in Excel. ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (ribbon)

Using Merge Fields

When creating a mail merge document, you use merge fields to indicate where the information from each record of your data ...

Discover More

Proper Comparisons for Dates in Merge Fields

How Word merges a data source with a document is controlled by merge fields. In those fields you may want to compare ...

Discover More

Merging Only a Date from Access

When you are merging data from an Access database, you may get more information than you want, especially when it comes ...

Discover More

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 0 + 1?

2016-12-14 09:23:20


Is it possible to compare two records. In the data source it will say:

Name Amount
Jane Smith $1,000
Jane Smith $ 500
Jane Smith $6,000
Bob Jones $2,000
Bob Jones $ 750

In may merge I want it to list all of Jane Smith's numbers. When it sees the name has changed I want it to do a new record with Bob's numbers. How would I write that?

2016-07-19 15:57:14


I'm not sure how to do this for my data. I need to print address labels and one of my fields is "farm name" which is frequently blank. When blank I want to just skip to the next field. For example for someone with a farm name the label should be:

Farm name
city, St zip

while for someone without it would print

city, st zip


2015-02-26 11:33:46


Hello Allen, I wonder if you can tell me what rule to use and how for my problem at hand. I need to use the mail merge with a data source. I am not using the mail merge for mailing reasons, instead I am trying to print labels for a production plant. Is there a way I can print X amount of copies for 1 record based off of the "quantity" field in the data source? Let's say that my record source has 3 lines/rows. Row1 has a quantity of 2, Row2 has a quantity of 3, and Row3 has a quantity of 1. I will need 2 of the same labels printed for the first row followed by 3 of the same labels for the second row, followed by 1 label for the third row. I look forward to hearing your suggestions!

2014-07-05 22:06:12

Thain Dikkers

Can not get this to work. How do you put the if statement in a Document so it will either print a line or not print the line? Do we need to start with Ctrl F9?

2014-02-02 04:41:01


Thank you for resolving! I didn't use Ctrl+F9 for inner brackets in if block.

2014-01-27 15:13:47



You need to add the OldCat column in your data source (Excel?) and make sure it is offset by one row from the Category column.

You also need to make sure that your merge fields are put into your Word document as actual fields, using Ctrl+F9 to insert each field (which creates the braces). The fact that you are getting back "Category}" with the ending brace indicates that you're not adding the merge field as an actual field.


2014-01-27 15:01:49


Hello Allen,
thank you for this tip using If ... Then ... Else in Mail Merge.

But your example doesnt work for me.
In MS Word I have following:
{ MERGEFIELD Category }
{ IF {MERGEFIELD Category} <> {MERGEFIELD OldCat} "first text" "second text" }

And the result for example for second record is:

Instead of:
second text

It takes me hours, but I cant figure out why it doesnt work.
Can you help me?

2013-11-11 07:58:01


You have poor data structure if changing the order of the records changes the meaning. Also, the point of a mail merge is to separate out each record -- what are you doing with it that you need to compare it to the last one?

(I'm certain I've commented on this topic before, but I can't seem to find it right now).

This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.