View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default VBA CODE FOR CONDITIONAL FORMULA

Hi again Vicky,

Not sure if you need it but the code can be enhanced to only include numeric
cells and exclude blank cells as below.

Sub ConditFormat()

'= 120 then red colour
'<50 then orange
'inbetween 50 and 120 then yellow

Dim c As Range

'Edit "Sheet1" to your sheet name
With Sheets("Sheet1")
For Each c In .UsedRange
If c.Value < "" And _
IsNumeric(c.Value) Then

Select Case c.Value
Case Is = 120
c.Interior.ColorIndex = 3
Case Is < 50
c.Interior.ColorIndex = 46
Case 50 To 120
c.Interior.ColorIndex = 6
End Select
End If
Next c
End With

End Sub

--
Regards,

OssieMac