title: "if not instr" doesn't work as i thought it should in vba
body: <p>I have a sheet with a list of contracts with a column for the supplier name  and one for the ending date, what I want to do is to make all passed dates red unless the contract is from a specific supplier.
  I had previously used <code>InStr</code> to check if a cell had a string inside so since I have just started with vba I thought of inserting the following in my loop</p>
  
  <pre><code>If Not InStr(LCase(Data.Cells(i, 4).Value), "flowserve") Then
      If CDate(Data.Cells(i, "h").Value) &lt; Date Then _
          Data.Cells(i, "h").Font.Color = -16776961
  End If
  </code></pre>
  
  <p>expecting it would colour passed dates of the contracts that do not have "flowserve" in the supplier name. But instead it just seems to colour all the passed dates as if the <code>InStr</code> was not finding anything anywhere. </p>
  
  <p>I then tried to do</p>
  
  <pre><code>If InStr(LCase(Data.Cells(i, 4).Value), "flowserve") Then
      'do nothing
  Else
      If CDate(Data.Cells(i, "h").Value) &lt; Date Then _
          Data.Cells(i, "h").Font.Color = -16776961
  End If
  </code></pre>
  
  <p>and this works as I wanted, so i'm guessing that the <code>Not</code> does not work as I thought.</p>
  
  <p>Now even if I kind of have a solution I was hoping that someone could explain what went wrong in the first code. Hope I was clear enough.</p>
  
  <p>thanks in advance everybody!</p>