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

Conditional Processing During a Mail Merge

Written by Allen Wyatt (last updated July 2, 2016)
This tip applies to Word 97, 2000, 2002, and 2003


6

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 (287) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) 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. ...

MORE FROM ALLEN

Selecting Tabs in Dialog Boxes

Want to move around in dialog boxes using just the keyboard? You'll love the ideas in this tip, then.

Discover More

Adding Many No-Width Optional Breaks

One of the special characters you can add in a document is the no-width optional break. Although originally designed for ...

Discover More

Using a Standard Format in a Suggested File Name

Many companies (and some individuals) use specific formats for naming their documents. If you want Word to recognize your ...

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 (menu)

Mail Merge and Data Source Documents become Unattached

When you create a mail merge document, you attach it to a data source that is the basis for the information to be merged ...

Discover More

Merging and Printing

When you merge information into a document, Word provides two different ways you can create your output. Here's an ...

Discover More

Printing Portions of Mail Merged Documents

When you use a data source to create a bunch of documents in a mail merge, you might not want to print all the documents ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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}] (all 7 characters, in the sequence shown) 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 2 + 2?

2019-06-14 03:36:54

Dustin Avery

Documate.org has a great tool for building conditional logic into contracts and contract sets.


2018-02-15 00:55:49

Mike

My Mail Merge used to work, but now it doesn't. I'm running. Win. 7 & Office 10. I have a Word document with merge fields embedded & an Excel data file. It doesn't follow the Rule "Skip Record if" and it doesn't fill in the merge codes into the merged docs. This is so for both hard copy & email merges. What to do? S/W or operator error? Thanks


2016-12-06 11:29:42

Placide

I need to know if there is any formula I can add in a mail merged cell for underlining a value under the average, ex. 4/10. The mailed value will be the number 4 underlined. I need your help.


2016-11-17 14:41:50

Warren

it is possible to have multiple conditions

e.g.

{IF {MERGEFIELD amount} > And {MERGEFIELD balance} > 0 "Text here"}


2016-11-02 14:55:47

John N

Is it possible to create a mail merge directory with distinct sections, each one pulling data based on multiple criteria?

For example: A first section pulls data from field A when field B falls within a certain date range and field C equals "one"; the second section pulls data from field A when field B falls within a certain date range and field C equals "two"; etc.


2016-07-02 08:38:52

Fred Burg

It may not be clear to the casual reader what the difference is between Next Record If and Skip Record If. Jumping to the next record would seem to be the same as ignoring the current record.


This Site

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

Videos
Subscribe

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.