We all know that when you want to do conditional formatting in Office, you use Excel. Right? Or maybe Access. But what if you want to merge some data from Excel into Word, then conditionally format some of the fields? Word doesn’t do conditional formatting!
Except, of course, it can.
For this I’m going to assume you have some data in Excel. Two columns headed “Data Number” and “Letter”. The Data Number is just 1 to 10, and the Letter is a, b or c.
Now in Word, I want to merge this data in. Only I want the letter to appear formatted with a red background (if it’s the letter a) and a green background (if it’s not). We create a new Word document, and set it up as a Mail Merge letter. Point Word at the Excel file as the data.
You can insert the fields as normal with the button on the toolbar, and get this:
But how to do the formatting? You need to manually enter the field and make some changes to it. To enter a field yourself, press CTRL-F9 and you’ll get a pair of braces { }. These aren’t normal ones, as you can tell by their formatting. Inside these, you’ll need an “if” command. The format for “if” in Word is:
{ if [CONDITION] [DO THIS IF TRUE] [DO THIS IF FALSE] }
so we can do the following:
Which will show the Letter field if Letter = “a”, and the Letter field if Letter != “a”. Which doesn’t do anything we couldn’t do already. However – you can format individual bits of that command, like this:
Can you guess what this does? Try it and see! Of course, you can also change the fonts and weights for the true and false. I’ve attached a file with the data and template I’ve used. Click here to get it!
How is the “if” inserted? It is to see but not how it gets there.Can you please elaborate?
Right click the field and choose “show field codes”, then just click in the code that appears and type.
Hi all,
Does anyone know how I can do a mail merge and use a 3 colour conditional formatting (like excel) but in word please? (0- red, 50- yellow, 100 – green). I am a beginner in mail merge, so any help would be greatly appreciated.
Many thanks in advance!