Red Amber Green Help Conditional Formatting

Clelv

New Member
Joined
Dec 19, 2016
Messages
33
Hi All,

I'm struggling with a query on Excel.

I have some cells which i would like to change colour to Red amber and Green depending on where the number falls within a reference table

So my information table will automatically change Cell A2, B2, C2, D2 to red, amber or green depending on where that number falls within table 2 - Reference data

Table 1

ABCD
1TempleSunChapelYard
215810

<tbody>
</tbody>

Table 2

ABCDEFGH
1REDAMBERGREENMAX
2FromToFromToFromTo
3Temple034671010
4Sun034561111
5Chapel045781212
6Yard08915162323

<tbody>
</tbody>

I have 3 formulas in conditional formatting for each of the four cells in table 1. I've been using:

For cell A2

=and(A2>=B3,A2<=C3) Colour Red
=and(A2>=D3,A2<=E3) Colour Amber
=and(A2>=F3,A2<=F3) Colour Green

And i do this 3 times for each of the cells in the information table 1 = A2, B2, C2 & D2.

This works sometimes but not always and i'm totally confused as to why that is!

Any help will be welcomed. Thanks in advance
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Can you give us details of an example where it does NOT work ?
And when you say it does not work, what exactly does it show ?
 
Upvote 0
Hi,

Thank you for responding.

It doesn't work when the number in cell B2 and D2 in Table 1 is the "From" Figure in Table 2. E.g 6 and 16. It doesn't return any colour, it just remains blank. But this condition works fine in the other cells in Table 1 and if i change the figure to 7 or 17 in Table 1 then the condition works.

The table above obviously isn't the table i'm using, and that table picks the figures in table 1 up from another worksheet in the same workbook. I get my cells to format using the original location of the data on the other worksheet to cut down on links etc.

The spreadsheet updates it'self each week and it seems that some weeks they all return correctly and then another time they don't.

I really just want to know if there should be any order to my conditional formatting formula's and if they ones i'm using SHOULD work and then i can go over it with a fine tooth comb (again!) and try to see where the fault is.

Thanks for all your help, it's driving me potty :)
 
Upvote 0
Hi,

Looking into this further, it seems that the conditional formatting doesn't like me working my conditions out from a figure that has an average formula behind it. If i over type the formula it works fine, if i replace it with the average formula it returns no colour. This is confusing though because it works fine on the 3 out of 5 cells, all using an average formula.

Thanks again
 
Upvote 0
Try rounding your values. Excel has a little problem with floating arithmetic errors that sometimes rears its ugly head.
See: https://support.microsoft.com/en-us...ithmetic-may-give-inaccurate-results-in-excel

So you may want to try re-writing your formulas like:
Code:
[COLOR=#333333]=and(ROUND(A2,0)>=ROUND(B3,0),ROUND(A2,0)<=ROUND(C3,0))[/COLOR]
That will round each value off to zero decimals. Change it as you see fit.
 
Upvote 0
Amazing. Thank you.

Really clever help and now i'm super pleased with the outcome now so thank you ;)

I half wondered if it was to do with the number not being whole but wouldn't of known how to correct it.

This site has been really useful to me over the last 2yrs!!
 
Upvote 0
Excellent! Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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