Dear Paul and Greg,
I would like to modify a bit the code to accomodate more than two cases. However, once I added the cases, the code still colors only the I and V as in the original solution. What I'm doing wrong?
Thank you
Daniel
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range, BkGrnd As Long
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "<[IV]>"
.Replacement.Text = ""
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
End With
Do While .Find.Execute
If .Information(wdWithInTable) = True Then
Set Rng = .Cells(1).Range
With Rng
.End = .End - 1
Select Case .Text
Case "I": BkGrnd = RGB(0, 112, 192)
Case "I-II": BkGrnd = RGB(155, 194, 230)
Case "II": BkGrnd = RGB(0, 176, 80)
Case "II-III": BkGrnd = RGB(146, 208, 80)
Case "III": BkGrnd = RGB(255, 255, 0)
Case "III-IV": BkGrnd = RGB(255, 230, 153)
Case "IV": BkGrnd = RGB(255, 192, 0)
Case "IV-V": BkGrnd = RGB(244, 176, 132)
Case "V": BkGrnd = RGB(255, 0, 0)
Case Else: BkGrnd = wdColorAutomatic
End Select
.Cells(1).Shading.BackgroundPatternColor = BkGrnd
End With
End If
.Collapse wdCollapseEnd
Loop
End With
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub