title: Function that changes the cell color
body: <p>I am creating a function where if a cell has <strong>Yellow</strong> color and if I enter <code>0</code> in that cell, then it pops up a message box <strong>Red</strong> then colors the cell <strong>Red</strong>. And then if I enter <code>1</code> it reverts the color to <strong>Yellow</strong>.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>Function ColorChange(range)
      If range.Interior.ColorIndex = 6 And range.Value &lt; 1 Then
          MsgBox "Project Delay!", vbCritical, "Attention required!"
          range.Interior.ColorIndex = 3
      Else
          If range.Interior.ColorIndex = 3 And range.Value &gt; 0 Then
              range.Interior.ColorIndex = 6
          End If
      End If
  End Function
  </code></pre>