View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Change the font color based on the value of the cell

If you really want VB code instead of the Conditional Formatting I
recommended earlier, then use this worksheet event code instead (where you
would change the A1 to the cell address of the "particular cell" you want to
have this functionality)...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0,0) < "A1" Then Exit Sub
If Target.Value Mod 2 = 1 Then
Target.Font.ColorIndex = 3
ElseIf Target.Value = "0" Or Target = "00" Then
Target.Font.ColorIndex = 4
Else
Target.Font.ColorIndex = 0
End If
End Sub

--
Rick (MVP - Excel)


"Robin" wrote in message
...
How do I create a macro or program to change the font color of a
particular
cell based on the value of the cell, e.g. 1 3 5 7, change the font color
to
red, if 0, 00 change font color to green and bold, thanks in advance