title: Excel VBA code to compare text strings in two columns and highlight certain text strings not the whole cell?
body: <p>I need to do a vba code to compare texts in two columns and highlight matched texts in the second column. I started on the code and below is what I got so far. It works fine on the first row, how to modify the code to apply this for the entire table not just the first row. I'm new to VBA and any help would be great. </p>
  
  <pre><code>Sub Test1()
    Dim strString$, x&amp;
    Dim rngCell As Range
  
    strString = Range("G2").Value
    Application.ScreenUpdating = False
    For Each rngCell In Range("S2", Range("S" &amp; Rows.Count).End(xlUp))
        With rngCell
            .Font.ColorIndex = 1
            For x = 1 To Len(.Text) - Len(strString) Step 1
                If Mid(.Text, x, Len(strString)) = strString Then .Characters(x, Len(strString)).Font.ColorIndex = 5
            Next x
        End With
    Next rngCell
    Application.ScreenUpdating = True
  End Sub
  </code></pre>