View Single Post
 
Old 11-14-2017, 09:15 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Maybe something like the following. Note the search is case sensitive.

Code:
Sub Macro1()
Dim oTable As Table
Dim oCell As Range
Dim i As Long
    For Each oTable In ActiveDocument.Tables
        For i = 1 To oTable.Range.Cells.Count
            Select Case True
                Case InStr(1, oTable.Range.Cells(i).Range.Text, "Science") > 0
                    Set oCell = oTable.Range.Cells(i).Range
                    oCell.End = oCell.End - 1
                    oCell.Font.Color = wdColorGreen
                Case InStr(1, oTable.Range.Cells(i).Range.Text, "Health") > 0
                    Set oCell = oTable.Range.Cells(i).Range
                    oCell.End = oCell.End - 1
                    oCell.Font.Color = wdColorRed
                    'etc
            End Select
        Next i
    Next oTable
lbl_Exit:
    Set oTable = Nothing
    Set oCell = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote