PDA

View Full Version : Solved: Conditional Format for percentage



slamet Harto
03-09-2010, 01:28 AM
hi there

I want to format Column CH based on value of percentage in column CI
Here's the conditions:
CONDITIONS:
Percent Colour Format
0% Brown
1% - 49.99% Black
50%-79.9% Red
80%-99.9% Yellow
>100% Green

Thanks for assistance

Bob Phillips
03-09-2010, 02:29 AM
Sub test()
Dim Str As Long

With ActiveSheet

For Each c In Intersect(.UsedRange, .Columns("CI")).Cells

If Len(c.Value) > 0 Then

If IsNumeric(c.Value) Then

Select Case c.Value * 100
Case Is = 0
.Cells(c.Row, "CH").Interior.ColorIndex = 53
Case 1 To 49.9
.Cells(c.Row, "CH").Interior.ColorIndex = 0
Case 50 To 79.9
.Cells(c.Row, "CH").Interior.ColorIndex = 3
Case 80 To 99.9
.Cells(c.Row, "CH").Interior.ColorIndex = 6
Case Is > 100
.Cells(c.Row, "CH").Interior.ColorIndex = 10
End Select
End If
End If
Next c
End With
End Sub

slamet Harto
03-09-2010, 03:02 AM
Hi Bob
That is wonderful, thank you so much.
Best regards,
Harto