VBA Code - conditional formatting

SridharK - Jul 16, 2018 at 11:29 PM - Latest reply: TrowaD 2410 Posts Sunday September 12, 2010Registration dateModeratorStatus August 14, 2018 Last seen
- Jul 19, 2018 at 11:25 AM
Hello,

in VBA, I want to do conditional formatting of cells in a column with below background & font colours.

Below 25: (RED Background-RGB-255-199-206) (Font-RGB-156-0-6)

25 to 35: (Yellow background-RGB-255-235-156) (Font-RGB-156-101-0)

>35: (Green background-RGB-198-239-206) (Font-RGB-0-97-0)

They want only these particular colour shades.

Please help.

SK
See more 

Your reply

2 replies

TrowaD 2410 Posts Sunday September 12, 2010Registration dateModeratorStatus August 14, 2018 Last seen - Jul 17, 2018 at 11:32 AM
0
Thank you
Hi SridharK,

Why use VBA for this, but if you "must", then use the macro recorder to see how it is done.

Best regards,
Trowa
Respond to TrowaD
TrowaD 2410 Posts Sunday September 12, 2010Registration dateModeratorStatus August 14, 2018 Last seen - Jul 19, 2018 at 11:25 AM
0
Thank you
Hi SK,

It seems that the macro recorder doesn't record much in this case.

Give this code a try:
Sub RunMe()
For Each cell In Range("A:A")
    If cell.Value <> vbNullString Then
        Select Case cell.Value
            Case Is < 25
                cell.Interior.Color = 13551615
                cell.Font.Color = -16383844
            Case 26 To 35
                cell.Interior.Color = 10284031
                cell.Font.Color = -16751204
            Case Is > 35
                cell.Interior.Color = 13561798
                cell.Font.Color = -16752384
        End Select
    End If
Next cell
End Sub 


Best regards,
Trowa
Respond to TrowaD