View Single Post
 
Old 10-19-2021, 03:31 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

This is the basic code I would start with to match with your sample doc. You can adjust the colours and add a font handler if you need it but the automatic font colour you already have might be adequate for that.
Code:
Sub TrafficLights()
  Dim aTbl As Table, aCell As Cell, sEff As String, sC2 As String
  For Each aTbl In ActiveDocument.Tables
    sEff = Trim(Split(aTbl.Cell(1, 1).Range.Text, vbCr)(0))
    If sEff = "Effectiveness" Then
      Set aCell = aTbl.Cell(1, 1).Next
      sC2 = aCell.Range.Text
      sC2 = Trim(Split(sC2, vbCr)(0))
      Select Case sC2
        Case "Weak"
          aCell.Shading.ForegroundPatternColor = wdColorLightOrange
        Case "Effective"
          aCell.Shading.ForegroundPatternColor = wdColorBlue
        Case "Adequate"
          aCell.Shading.ForegroundPatternColor = wdColorGreen
        Case "Not Applicable"
          aCell.Shading.ForegroundPatternColor = wdColorIndigo
        Case Else
          aCell.Shading.ForegroundPatternColor = wdColorWhite
      End Select
    End If
  Next aTbl
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote