Conditional Format Tables in MS Word

S

S1lverface

I would like to change the Font Colour of the first 5 rows of my table in
Microsoft Word, based on the word in the Row 1 Column 1.

For example; table has 5 Rows and 5 columns. Cell Row 1 Column 1 will either
say Yes, No, Maybe. I the font colour of all 5 rows to change depending on
which word.
e.g. Yes = Red, No = Green, Maybe = blue

Can anyone help, thanks.
 
D

Doug Robbins - Word MVP

Use the following:

Dim colrange As Range
Dim Criteria As Range
With ActiveDocument.Tables(1)
Set Criteria = .Cell(1, 1).Range
Set colrange = .Cell(1, 1).Range
colrange.End = .Cell(5, 5).Range.End
End With
Criteria.End = Criteria.End - 1
Select Case Criteria.Text
Case "Yes"
colrange.Font.Color = wdColorRed
Case "No"
colrange.Font.Color = wdColorGreen
Case Else
colrange.Font.Color = wdColorBlue
End Select


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
S

S1lverface

Thanks Doug, much appreciated.

It doesn't seem to like the code if the cell contains the keyword as a
result of a 'Mail Merge' !!
Is there a wy to work around this ?

Thanks again.
 
D

Doug Robbins - Word MVP

What does "It doesn't seem to like the code" mean? Does it mean that the
range is always turned Blue?

If that is the case, I would suggest that the reason is that you are not
running the code on a document that was created by executing the merge.

What type of mail merge is it?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top