title: Using wildcards in VBA for Conditional Formatting (Excel 2003)
body: <p>I worked up the following VBA to add a bunch of conditional formatting to a worksheet in Excel 2003 (which only allows 3 conditions otherwise), but it won't function correctly with wildcards. If I substitute the wildcards for exact values, it runs correctly. I suspect the last statement about &lt;> may require adjusting, but I don't know how to jive the LIKE "Wildcard" with &lt;> at the end. VBA code below:</p>
  
  <pre><code>    Private Sub Worksheet_Change (ByVal Target As Range)
      Set MyPlage = Range(“C3:I11,C13:I34”)
          For Each Cell in MyPlage
  
      If Cell.Value Like “A*” Then
              Cell.Interior.ColorIndex = 38
      End If
      If Cell.Value Like “B*” Then
              Cell.Interior.ColorIndex = 35
      End If
      If Cell.Value Like “C*” Then
              Cell.Interior.ColorIndex = 34
      End If
      If Cell.Value Like “D*” Then
              Cell.Interior.ColorIndex = 40
      End If
      If Cell.Value &lt;&gt; “A*” And Cell.Value &lt;&gt; “B*” And Cell.Value &lt;&gt; “C*” And Cell.Value &lt;&gt; “D*” Then
      Cell.Interior.ColorIndex = xlNone
      End If
  
      Next
  End Sub
  </code></pre>