View Single Post
  #6  
Old May 21st, 2010, 07:34 AM posted to microsoft.public.excel.newusers
Max
external usenet poster
 
Posts: 8,574
Default Conditional Formatting

John, adapt the sub below (courtesy of a reply by MVP Jeff in another forum)
to suit the range to be colored, depending on the numbers returned by the
formulas in that range. As-is, it presumes that the range you want colored is
IM2:IM100, which contains formulas returning the numbers 1-8. I've tested it
and it works fine

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor, fcolor As Integer
Dim rng As Range
For Each rng In Range("IM2:IM100")
Select Case rng.Value
Case 1
icolor = 6
fcolor = 6
Case 2
icolor = 12
fcolor = 12
Case 3
icolor = 7
fcolor = 7
Case 4
icolor = 53
fcolor = 53
Case 5
icolor = 15
fcolor = 15
Case 6
icolor = 42
fcolor = 42
Case 7
icolor = 50
fcolor = 50
Case 8
icolor = 13
fcolor = 13
Case Else
End Select
With rng
.Interior.ColorIndex = icolor
.Font.ColorIndex = fcolor
End With
Next
End Sub

--
Max
Singapore
---