View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Conditional formatting for more than 3 variables

Maybe this, change the colours to suit

'-----------------------------------------------------------------
Private Sub Worksheet_Calculate()
'-----------------------------------------------------------------
Const WS_RANGE As String = "H1:H10"
Dim cell As Range

For Each cell In Me.Range(WS_RANGE)
With cell
If .Value = 1 And .Value < 10 Then
Select Case .Value
Case Is 9: .Interior.ColorIndex = 10 'green
Case Is 8: .Interior.ColorIndex = 3 'red
Case Is 7: .Interior.ColorIndex = 5 'blue
Case Is 6: .Interior.ColorIndex = 6 'yellow
Case Is 5: .Interior.ColorIndex = 6 'yellow
Case Is 4: .Interior.ColorIndex = 10 'green
Case Is 3: .Interior.ColorIndex = 3 'red
Case Is 2: .Interior.ColorIndex = 5 'blue
Case Is 1: .Interior.ColorIndex = 6 'yellow
Case Else: .Interior.ColorIndex = xlColorIndexNone
End Select
End If
End With
Next cell

End Sub

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Emile" wrote in message
...
Bob:

That worked perfect! Thank you.
In an effort to get help with this question (which I could never have
figured out without your help) I simplified my question somewhat.
The numbers 1-9 as previously mentioned are actually not whole numbers.
They have two decimal places. So when the sum (that I am evaluating) is
anything more than a whole number in it, I get no color at all.
Example 4.65 returns no color
Example 4.00 returns the assigned color

Sorry to be a bother, but your help is greatly appreciated.

Emile