"This worked like a dream! I am very rusty with VBA though, can someone please tell me how to ask it to perform multiple actions. I forget which part of the code I need to copy for it to repeat.

I would like it to find the following and shade the cell that colour:

text = "W4"
backgroundColor = wdRed


text = "W5"
backgroundColor = wdRed


text = "W6"
backgroundColor = wdYellow


text = "W7"
backgroundColor = wdYellow


text = "W8"
backgroundColor = wdGreen


text = "W9"
backgroundColor = wdGreen


Thanks


Quote Originally Posted by AbbyPi View Post
If I am understanding correctly, those instructions don't change the background color for the entire cell, just the text background of the specified field, so that if there are other merge fields or text in the cell, it will only highlight the specified field and not the whole table cell.

I was able to conditionally shade the entire cell by running this VBA macro after the mail merge.

Sub color()
Dim r As Range, text As String, backgroundColor As WdColorIndex
Set r = ActiveDocument.Range
text = "TOXIN"
backgroundColor = wdGray25
With r.Find
Do While .Execute(FindText:=text, MatchWholeWord:=True, Forward:=True) = True
r.Cells(1).Shading.BackgroundPatternColorIndex = backgroundColor
Loop
End With
End Sub