Cell color change based on values

kashifjillani

New Member
Joined
Jul 26, 2011
Messages
47
Hi there,

I wonder if someone know how to change the background cell color based on value ranges(s)

I tried conditional formatting but it works between two values only, in my assignment I want to show:

River levels in relation to flood class
>=2m <2.6m is minor flood (background turns green)
>=2.6 <3 m is moderate flood (background turns yellow)
>=3m major flood (background turns red)

I hope it is possible in Office 2007

Cheerio
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi
What is the range of cells this will apply to ??
AND
What happens when River level is <2m ??
 
Upvote 0
Hi
What is the range of cells this will apply to ??
AND
What happens when River level is <2m ??


This classification would apply to whole row say BV7 to GK7 (2m, 2.6m, 3m)

Similarly other rivers with different classification BV8 to BV8 (3m, 3.4m, only minor and moderate flood nod classification for major)

To your second question, below 2m level the cell will stay sky blue colored.

Thanks mate for your prompt attempt, wish to hear from you today again.

Cheerio.:)
 
Upvote 0
Try this.....but the colours may be slightly different
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
    If Not Intersect(Target, Range("BV7:GK8")) Is Nothing Then
        Select Case Target
                Case Is < 2
                        icolor = 8
                Case Is < 2.6
                        icolor = 4
                Case Is < 3
                        icolor = 6
                Case Is > 3
                        icolor = 3
        End Select
        Target.Interior.ColorIndex = icolor
    End If
End Sub
 
Upvote 0
Try this.....but the colours may be slightly different
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
    If Not Intersect(Target, Range("BV7:GK8")) Is Nothing Then
        Select Case Target
                Case Is < 2
                        icolor = 8
                Case Is < 2.6
                        icolor = 4
                Case Is < 3
                        icolor = 6
                Case Is > 3
                        icolor = 3
        End Select
        Target.Interior.ColorIndex = icolor
    End If
End Sub



+
+
+

Thanks Michael,

It works, :biggrin:

Just one thing more, I want to apply it to other rows as well

e.g. BV8:GV8

BV9:GV9 and so on (the classification would keep changing with each row)

I tried to copy and paste under your code, but it didnt work.

Can you suggest on it please,

Thanks again,
 
Upvote 0
Hi there,

I wonder if someone know how to change the background cell color based on value ranges(s)

I tried conditional formatting but it works between two values only, in my assignment I want to show:

River levels in relation to flood class
>=2m <2.6m is minor flood (background turns green)
>=2.6 <3 m is moderate flood (background turns yellow)
>=3m major flood (background turns red)

I hope it is possible in Office 2007

Cheerio



You can still use conditional formatting for this. in 2007, follow the below.
1. Highlight the block of cells you would like to conditional format.
2. Select conditional formatting and "manage rules"
3. Select "New Rule"
4. Use "format only cells that contain" and the drop down to "between", then write the first condition. ("between" 2m and 2.59999),
5. Follow #3 through #5 again until all conditions are met. the last one, instead of being between would be "greater than or equal to" 3m.
You should also have a condition to "less than" 2m, which you stated in the previous reply was sky blue. You can select the colors more easily this way.

Hope this helps.
 
Upvote 0
You can still use conditional formatting for this. in 2007, follow the below.
1. Highlight the block of cells you would like to conditional format.
2. Select conditional formatting and "manage rules"
3. Select "New Rule"
4. Use "format only cells that contain" and the drop down to "between", then write the first condition. ("between" 2m and 2.59999),
5. Follow #3 through #5 again until all conditions are met. the last one, instead of being between would be "greater than or equal to" 3m.
You should also have a condition to "less than" 2m, which you stated in the previous reply was sky blue. You can select the colors more easily this way.

Hope this helps.



Thanks Cory,

I didnt know I would find solution (two instead of one) for this problem,

Thanks again to Michael and You,

Regards,:)
 
Upvote 0
There is always more than one way to solve the problem....as long as you have a solution !!
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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