Mail Merge can handle conditional rules such as If… Then… Else… to display different text depending on the information in the data source record.
Normally these rules are quite simple tasks such as; if the member joined within the last month, or if they have a family membership.
Sometimes though you may need to use multiple conditions. For example, you may want to check if a member of a club had a Gold, Silver or Bronze membership. The new price of their membership depends on what membership they have.
Begin by inserting a basic If… Then… Else… rule. This gives you a head start with typing the rules by inserting the structure of the condition. It’s easier to expand on this rule, than write one from nothing.
- Click on the Rules button in the Write & Insert Fields group of the Mailings tab
- Select If… Then… Else… from the list
- Build the condition by selecting the Field name and Comparison operator from the lists and then typing the value you want to check against in the Compare to box
- Type the text you want to show if the condition is true in the Insert this text box
- Click Ok
The text will show in the document if it matches the condition for the first record from the data source.
To expand on this criteria we need to see the field code. Press Alt + F9 to view the field code. The code will look like below;
{ IF { MERGEFIELD Membership } = “Gold” “66” “” }
To use multiple conditions, you can add more If’s to the code. The example below shows the different amounts being displayed for the different types of membership.
{ IF { MERGEFIELD Membership } = “Gold” “66” { IF { MERGEFIELD Membership } = “Silver” “55” { IF { MERGEFIELD Membership } = “Bronze” “46” } } }
Pressing Alt + F9 at any point will switch between showing the field codes or not.
ted hartwell says
this is all well and good but what about the other rules.
Several sites I visited only explain the if then statement.
What do the other rules do and how do I properly use them. That was what i was really looking for.
Kishor says
How to insert another merged field in IF..Then..Else, Please guide.
computergaga_blog says
Hi Kishor,
Check out this link for inserting merge fields into an If Then Else statement.
Emma K says
Link not working 🙁
computergaga says
Thanks Emma. Yes, that link in the comments area was to a page on the office.microsoft website. It is no longer available. Thanks for letting me know.
James says
How do I add say two combined conditions? IF A and B then C, otherwise blank?
Alan Murray says
I’m not sure if doing more complicated conditions is possible James. It could be something that can e done in the VBA side.
But this is going beyond the requirements of Word, and can probably be added as a column the the data source that you merge with. The Excel spreadsheet or database query. Better to to add the column there than in Word.
Michael Bracken says
{ IF { MERGEFIELD First-Item } = “A” “{ IF { MERGEFIELD Second-Item } = “B” “C” “” }” “”}
Carolee Moreno says
Can you tell me how to make this statement eliminate the blank lines upon merging? If I have a value in the merge file, I want it to just leave that item blank and eliminate the line on the merged document and move on to the next line. I have ten of these statements like the one below but can’t get rid of the white space if the second if statement has a value in the table.
{IF {MERGEFIELD Bulletin_Board} = “” “Join the Bulletin Board” {IF {MERGEFIELD “Bulletin_Board} = “Bulletin Board User” “¶
}}
So, if mergefield is empty, I want it to show “join the bulletin board”, but if the mergefield already has a value in it, I do not want it to show the value, but rather do nothing and eliminate the white space on the merged document.
Stacey Coleman says
What is the best way to find the extra spacing between paragraphs in your merged letter. The rules are fine but I can’t find the extra spaces.