(Solved) – Function that changes the cell color

  • by

I am creating a function where if a cell has Yellow color and if I enter 0 in that cell, then it pops up a message box Red then colors the cell Red. And then if I enter 1 it reverts the color to Yellow.

Here’s my code:

Function ColorChange(range)
    If range.Interior.ColorIndex = 6 And range.Value < 1 Then
        MsgBox "Project Delay!", vbCritical, "Attention required!"
        range.Interior.ColorIndex = 3
        If range.Interior.ColorIndex = 3 And range.Value > 0 Then
            range.Interior.ColorIndex = 6
        End If
    End If
End Function

Leave a Reply

Your email address will not be published. Required fields are marked *