Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. 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 July 18, 2016)


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, and 2013. 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. ...


Finding a Lost Menu Bar

Once in a while Word can get confused and stop displaying an object you need to fully use Word. If your menu bar suddenly ...

Discover More

Document is Too Large for Word to Handle

Imagine trying to open a familiar document one day, only to find that Word gives you an error message that the file is ...

Discover More

Keep with Previous

Word allows you to format a paragraph so that it is on the same page as whatever paragraph follows it. You may want, ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (ribbon)

Creating Files with Mail Merge

When you use mail merge to create a document that incorporates all your data source records, you end up with a large ...

Discover More

Automatically Determining a Due Date

When you are doing a mail merge in Word, you may need to calculate a date sometime in the future. Word doesn't include an ...

Discover More

Merging and Printing a Series of Documents

Do you need to merge and print a number of documents in a particular order? Perhaps the best approach is to record a ...

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 five more than 4?

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.