When you use Word Mail Merge to generate letters, envelopes, or labels, the Address Block field inserts a formatted name and address from your data source. But sometimes you need the Address Block to show different information depending on a value in your data, such as showing a company name for business contacts and a personal name for individual contacts. Word does not allow you to place an IF field directly inside an Address Block field. This article explains how to work around that limitation by inserting IF/ELSE conditionals around or instead of the Address Block field, using the Word field code system. You will learn the exact syntax and steps to create conditional address content that changes based on any field in your data source.
Key Takeaways: Using IF/ELSE Conditionals With Address Block in Mail Merge
- Alt+F9 to toggle field codes: Reveals the underlying field code of the Address Block so you can edit or replace it with a conditional IF field.
- Ctrl+F9 to insert a new field: Creates a pair of curly braces where you can type the IF field code manually.
- Merge field names from your data source: Must match the column headers exactly for the IF condition to evaluate correctly.
- Nested field codes for complex conditions: You can combine multiple IF fields or use the Address Block field as one of the true/false outputs.
How the Address Block Field Works and Why IF/ELSE Cannot Go Inside It
The Address Block field in Word Mail Merge is a single field code that pulls data from mapped fields in your data source. When you insert an Address Block, Word creates a field code similar to this:
{ ADDRESSBLOCK \c "en-US" }
This field code tells Word to generate a formatted block using the recipient name, street address, city, state, and postal code. You cannot insert an IF field inside the curly braces of the ADDRESSBLOCK field itself. If you try, Word ignores the IF syntax or produces an error.
The workaround is to replace the Address Block entirely with an IF field that contains the address components you need. Alternatively, you can keep the Address Block and wrap it inside an IF field so it only appears when a condition is true. The IF field syntax in Word follows this structure:
{ IF [field name] [operator] [value] [true text] [false text] }
The field name must match a column header in your data source. The operator can be =, <>, >, <, >=, or <=. The true text and false text can include plain text, other merge fields, or even a nested ADDRESSBLOCK field.
Steps to Insert an IF/ELSE Conditional That Replaces the Address Block
These steps assume you have already connected your main document to a data source and inserted an Address Block. You will replace that Address Block with a conditional IF field that shows different address content based on a field value.
- Reveal the field code of the existing Address Block
Press Alt+F9 to toggle field code display. The Address Block field code appears inside curly braces. Select the entire field including the braces, then press Delete to remove it. Press Alt+F9 again to return to normal view. - Insert a new IF field
Press Ctrl+F9 to insert a pair of empty field braces. Your cursor will be inside the braces. Type the following field code, replacing the placeholders with your actual data field names and values:IF [FieldName] = "[Value]" "[TrueText]" "[FalseText]"
For example, if your data source has a column named “ContactType” and you want to show “Company Name” when ContactType equals “Business” and “First Name Last Name” when ContactType equals anything else, type:IF ContactType = "Business" "{ MERGEFIELD Company }" "{ MERGEFIELD FirstName } { MERGEFIELD LastName }" - Add the rest of the address fields
After the IF field, press Enter and insert the remaining address merge fields such as Street, City, State, and ZIP. You can insert each merge field by pressing Ctrl+F9 and typingMERGEFIELD [FieldName]or by using the Insert Merge Field button on the Mailings tab. The final result should look like this:{ IF ContactType = "Business" "{ MERGEFIELD Company }" "{ MERGEFIELD FirstName } { MERGEFIELD LastName }" }{ MERGEFIELD Street }{ MERGEFIELD City }, { MERGEFIELD State } { MERGEFIELD ZIP } - Test the conditional merge
On the Mailings tab, click Preview Results. Use the arrow buttons to cycle through records. Verify that the IF condition shows the correct name for each contact type. If the condition does not evaluate as expected, check that the field name in the IF statement matches the column header exactly, including case and spaces.
Steps to Wrap an Existing Address Block Inside an IF Field
If you want to keep the Address Block format but only show it when a condition is true, wrap the Address Block inside an IF field. This is useful when you want to suppress the address for certain records, such as when a “DoNotMail” field is set to Yes.
- Insert the Address Block as normal
On the Mailings tab, click Address Block and configure the fields as needed. Click OK to insert it. - Cut the Address Block to the clipboard
Select the Address Block field (including the brackets if field codes are visible) and press Ctrl+X. - Insert an IF field and paste the Address Block inside
Press Ctrl+F9 to create empty field braces. Type the IF condition, but leave the true text empty. Press Ctrl+V to paste the Address Block into the false text position. For example, to hide the address when DoNotMail equals Yes, type:IF DoNotMail = "Yes" "" "{ ADDRESSBLOCK \c "en-US" }"
Press F9 to update the field, then press Alt+F9 to return to normal view. - Preview the results
Click Preview Results on the Mailings tab. Records with DoNotMail set to Yes show a blank line where the address would appear. Records with any other value show the full Address Block.
Common Mistakes and Limitations When Using IF/ELSE With Address Block
The IF field shows nothing or the wrong text
The most common cause is a mismatch between the field name in the IF statement and the column header in the data source. Field names are case-sensitive and must include spaces exactly as they appear. Open your data source in Excel and verify the exact column header text. Also, ensure the value in the IF condition is wrapped in straight double quotes, not curly quotes.
Word displays the field code instead of the address
This happens when field codes are toggled on. Press Alt+F9 to hide the field codes and show the merged result. If the problem persists, select the entire document and press F9 to update all fields.
The IF field only works for text comparisons, not numbers or dates
Word IF fields compare text values. If your field contains numbers or dates, Word converts them to text before comparison. For numeric fields, use the = operator with the number as text, such as IF Age = "25". For dates, use the date as text in the same format as your data source, for example IF StartDate = "1/1/2025". Word does not support date arithmetic inside IF fields.
Nested IF fields become unreadable
You can nest IF fields by placing one IF field inside the true or false text of another. However, each nested field requires its own set of Ctrl+F9 braces. For complex logic, consider using a calculated field in your data source (such as an Excel formula) instead of nesting multiple IF fields in Word.
IF/ELSE Conditional vs Address Block: Key Differences
| Item | IF/ELSE Conditional Field | Address Block Field |
|---|---|---|
| Definition | A field code that displays one of two text strings based on a condition | A preformatted field that combines name, company, and address fields from your data source |
| Customization | You control every character of the output | Word controls the formatting based on your locale and field mapping |
| Conditional logic | Built-in IF/ELSE logic | No conditional logic; always displays the mapped fields |
| Field code complexity | Requires manual typing of field names and values | Inserted automatically with a dialog box |
| Best use case | When you need different address content based on a data field | When all records use the same address format with the same fields |
Use an IF/ELSE conditional when your data contains a field that determines which address components to show. Use the Address Block when every record has the same set of address fields and you want Word to handle the spacing and punctuation automatically.
You can now create mail merge documents that show different address content based on any field in your data source. Start by identifying the field that will act as the condition. Write the IF field code with the exact field name and value. Test with Preview Results to confirm the output. For advanced scenarios, try nesting a second IF field inside the true or false text to handle a third condition, or use the Address Block as the false text to fall back to a default formatted address.