Link to home
Start Free TrialLog in
Avatar of Wonderwall
Wonderwall

asked on

Word Mail merge shifting fields if blank

Aloha I am using mail merge for the first time pretty successfully at thi spoint but I know there is alot more that can be done. Is there a way if a value is returned in a column that you can shift the bottom rows up. for example.

I dont want this
Ted Turner
123 main st.

Atlanta GA, 01921

I want this
Ted Turner
123 main st.
Atlanta GA, 01921

Avatar of honestman31
honestman31

in the mail merge Recipients  sort by names then just uncheck the empty names
see this attachment
ZA001110953.gif
Avatar of Wonderwall

ASKER

Ok, based on the example you have above I would have a Street address 2 which would have apt # lets say. In most cases this would be blank if it is then I need the city, state and zip to move up. I am wondering how do I chcek for a specific value and if it is blank or is equal to a value I don't want to print can I shift the rows printed up?

 
Avatar of Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Hello,

you can edit the field codes in Word to skip empty fields.

Hit Alt-F9 to see all Field codes. It will look something like

{ MERGEFIELD  "name" }
{ MERGEFIELD   "address1" }
{ MERGEFIELD   "address2" }
{ MERGEFIELD  "city" }

If you want to change the settings to skip the "address2" field if it is empty, follow these steps:

Highlight the line with "address2", then hit Ctrl-F9. This will encase the merge field into a new field, putting brackets before and after it. Then edit this to look like:

{ MERGEFIELD  "name" }
{ MERGEFIELD   "address1" }
{ IF { MERGEFIELD   "address2" } <> "" "{MERGEFIELD "address2" }
" ""}{ MERGEFIELD  "city" }

You can simply type the IF next to the new bracket, then add the <> signs. To insert the second Mergefield, hit Ctrl-F9 again after the <> "" " 
Then manually type MERGEFIELD "address2" into the new set of brackets. Note that the paragraph mark sits inside a pair of double quotes.

The syntax for the IF statement in Word Field codes is { IF <condition> "this is printed on true" "this happens on false" }

Note that the false action is just an empty string and no paragraph mark after that. Then the "city" field will follow directly after the address1.

cheers, teylyn
Ok great one more thing if I wanted to not print a column value if it hit a specific value, let's say in the case "Apt 2" then I am assuming I can use this? Mahalo

 MERGEFIELD  "name" }
{ MERGEFIELD   "address1" }
{ IF { MERGEFIELD   "address2" } <> "Apt 2" "{MERGEFIELD "address2" }
" ""}{ MERGEFIELD  "city" }

ASKER CERTIFIED SOLUTION
Avatar of Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thx dude