Change cell color based on a range of values

2k05gt

Board Regular
Joined
Sep 1, 2006
Messages
157
Column C2 - C20000
12.99 - 12.00 = green
11.99 - 11.00 = orange
10.99 - 10.00 = Red

Column D2 - D20000
100.00 - 349.99 = green
350.00 - 549.99 = orange
550.00 - 799.99 = Red

Column E2 - E20000
0-24 = blue
25-49 = green
50-74 = orange
75-100 = Red

there are too many options for using conditional formatting, any ideas?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Something like this should work:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iCTR As Long
    If Target.Column = 3 Then
        For iCTR = 2 To 20000
            If Range("C" & iCTR).Value >= 12 And Range("C" & iCTR).Value <= 12.99 Then Range("C" & iCTR).Interior.Color = 5287936       'green
            If Range("C" & iCTR).Value >= 11 And Range("C" & iCTR).Value <= 11.99 Then Range("C" & iCTR).Interior.Color = 39423         'orange
            If Range("C" & iCTR).Value >= 10 And Range("C" & iCTR).Value <= 10.99 Then Range("C" & iCTR).Interior.Color = 255           'red
        Next iCTR
    End If
    If Target.Column = 4 Then
        For iCTR = 2 To 20000
            If Range("D" & iCTR).Value >= 100 And Range("D" & iCTR).Value <= 349.99 Then Range("D" & iCTR).Interior.Color = 5287936     'green
            If Range("D" & iCTR).Value >= 350 And Range("D" & iCTR).Value <= 549.99 Then Range("D" & iCTR).Interior.Color = 39423       'orange
            If Range("D" & iCTR).Value >= 550 And Range("D" & iCTR).Value <= 799.99 Then Range("D" & iCTR).Interior.Color = 255         'red
        Next iCTR
    End If
    If Target.Column = 5 Then
        For iCTR = 2 To 20000
            If Range("E" & iCTR).Value > 0 And Range("E" & iCTR).Value <= 24 Then Range("E" & iCTR).Interior.Color = 16737792           'blue
            If Range("E" & iCTR).Value >= 25 And Range("E" & iCTR).Value <= 49 Then Range("E" & iCTR).Interior.Color = 5287936          'green
            If Range("E" & iCTR).Value >= 50 And Range("E" & iCTR).Value <= 74 Then Range("E" & iCTR).Interior.Color = 39423            'orange
            If Range("E" & iCTR).Value >= 75 And Range("E" & iCTR).Value <= 100 Then Range("E" & iCTR).Interior.Color = 255             'red
        Next iCTR
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,453
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top