View Single Post
 
Old 03-24-2022, 05:07 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
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

You were almost there.
I changed to Selection.Tables to make it easier to test for me so you can ignore that.
Two problems with your code is that the range.text includes more than just the text you can see so I changed this to just sample the first character in the range. Second problem is how to colour the entire row (.Cell needs a row AND column reference).
Code:
Sub Demo()
  Dim rw As Integer
  With Selection.Tables(1)
    For rw = 2 To 5
      If .Cell(rw, 4).Range.Text Like "5*" And .Cell(rw, 5).Range.Text Like "A*" Then
        .Rows(rw).Shading.BackgroundPatternColorIndex = wdDarkRed
      End If
    Next
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote