If Then Field in Mail Merge

itgolfer
itgolfer used Ask the Experts™
on
I'm using Word 2013 to create a mail merge from an Excel spreadsheet. When I'm doing the address, I'm using the columns for Name, Address Line 1, Address Line 2 and City,State,Zip. A majority of the customers don't have an second address line so I'm wondering how I can create this? If there is nothing in the Address Line 2 cell, then I just have a blank space in the mail merge. Is there a way to have an If/Then statement or something that says to not display it unless there is something in that field?

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Microsoft Excel Expert
Top Expert 2014
Commented:
there is a very good video toturial here
from Excelvideotraing site

you can download the attachment from the site as well.   it has the option of address line 2

this will get you started, but if you already have a code and you just want to add addtional address line, then please post your code here and we amend it for you.
GrahamSkanRetired
Top Expert 2012
Commented:
If a line is completely blank, then merge process will omit it altogether. In current Word versions, you would have to use VBA to change that default.
If there is something else on the line (such as Addr2:),  then an IF field would be appropriate.

Show the field codes with the Alt + F9 toggle, and the formatting makes with the Show/Hide button (¶) so that the line
Addr2: <<Address2>>
looks like
Addr2: { MERGEFIELD Address2 }¶
Select the line and hit Ctrl+F9 to surround it with an empty field and type in this text,
{ IF { MERGEFIELD Address2 } = "" "" "Addr2: { MERGEFIELD Address2 }¶
"}
The field can be copied in the usual way and except the field delimiters, the rest of the text can be typed as usual.

You can hide the field codes in the document using the  Alt+ F9 toggle again. However, the merge fields which are now embedded will no longer be visible.
the default paragraph formatting for merge fields adds trailing space as well as line spacing, if you select all the fields and remove the trailing space in Paragraph formatting you might find you can achieve the result you want

Author

Commented:
Thanks for the feeback. After looking, I only had around 26 that had a second line address so I just added the second line for those, printed them and then removed it. Then I printed the rest with just the one address line.
That's good operational practice ! us IT people frequently look for the 'perfect' answer with high automation and failing to recognise a bit of manual kicking around may be the best way - glad you got a resolution

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial