View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default VBA code for 5-rule Conditional Formating

'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "A1" '<=== change to suit
Dim ci As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case <=59: ci = 5 'blue
Case <=69: ci = 10 'green
Case <=79: ci = 6 'gold
Case <=80: ci = 46 'orange
Case <=100: ci = 1 'black
End Select
.Offset(1, 0).Interior.ColorIndex = ci
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Antonio" wrote in message
...
Hi Bob, more specifically, if the cell is <=59 the cell itself becomes
blue,
if it's <=69 it becomes green, if it's <=79 it becomes yellow, if it's
<=89
it becomes orange and if it's <=100 it becomes black.