philipwaldram
New member
- Local time
- Today, 13:25
- Joined
- Aug 26, 2008
- Messages
- 6
Hi
I'm trying to use a piece of code to change the colour of a cell depending on the answer from that cells formula.
E.g. =a1+b1+c1 in cell d1
If the answer to the formula in d1 is 1 the cell colour needs to be red, if the answer is 2 the colour needs to be yellow and any other numbers green.
If Range("d1") = 1 Then
Selection.Interior.ColorIndex = 3
ElseIf Range("d1 = 2 Then
Selection.Interior.ColorIndex = 6
Else
Selection.Font.ColorIndex = 4
Selection.Interior.ColorIndex = 4
End If
But this doesn't work with the calculation. It only works when the number is typed in the cell.
Is is something like:
Range("d1").value
Thanks
Phil
I'm trying to use a piece of code to change the colour of a cell depending on the answer from that cells formula.
E.g. =a1+b1+c1 in cell d1
If the answer to the formula in d1 is 1 the cell colour needs to be red, if the answer is 2 the colour needs to be yellow and any other numbers green.
If Range("d1") = 1 Then
Selection.Interior.ColorIndex = 3
ElseIf Range("d1 = 2 Then
Selection.Interior.ColorIndex = 6
Else
Selection.Font.ColorIndex = 4
Selection.Interior.ColorIndex = 4
End If
But this doesn't work with the calculation. It only works when the number is typed in the cell.
Is is something like:
Range("d1").value
Thanks
Phil