Hi folks,
I have a Word document with cells that contain text like "Clear" or "Clear evidence" or "Bottom 30%", and I have a macro that finds cells with the text "Clear" or "Bottom" and colours them green or red respectively.
However, the macro only works when that text is the entire contents of the cell. It won't colour "Clear evidence" green or "Bottom 30%" red.
I've looked around for Word macros that might do this via wildcards, but they all seem to use the searchText command, which my current macro does not. I'm happy to switch, but this macro is the only way I've found to colour text (I found it on the web somewhere).
Here is the macro as it currently stands:
Sub TestINTERNAL(VariableName As Document)
Dim oTbl As Table
Dim oCel As Cell
Dim oRng As Range
For Each oTbl In ActiveDocument.Tables
For Each oCel In oTbl.Range.Cells
Set oRng = oCel.Range
oRng.End = oRng.End - 1
Select Case oRng.Text
Case "Bottom"
oCel.Shading.BackgroundPatternColor = RGB(247, 150, 70)
Case "Clear"
oCel.Shading.BackgroundPatternColor = RGB(155, 187, 89)
End Select
Next
Next
End Sub
Thanks for your help!
Chris
Bookmarks