IF cell Contains "text" then lookup "Colour"

vxs

Board Regular
Joined
Dec 10, 2008
Messages
61
Hi all,
I need to format a column/set of cells where each cell has some text in it, and depending on a defined list elsewhere that text does a contains lookup to see whether to colour that cell in Green/Amber or Red. I was going to use the conditional formatting traffic lights but I dont know how to set this rule and do the lookup.

I could use the table below to find out or lookup what colour to use OR the first column with VW in it, in my spreadsheet already has the VW cell conditioned to the correct background colour so could just ask the cell to copy that formatting of cell contains the word VW?

Either-way I am not sure how to go about this, would preferably like to use the traffic light conditional formatting optional but don't know how to match these to the table below. How would I go about this?

Example

VWGreen
FiatAmber
BMWRed
Land RoverAmber
KiaGreen
SkodaAmber
HondaRed
JeepRed

<tbody>
</tbody>


Any help much appreciated.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
so you have a column of words and you want those words to be in cells that have a certain background color based on the example set above?
 
Upvote 0
I see a couple of options. The CF icons are nice, but they don't allow as flexible formulas as you can do when you design your own.

When you said that the column contained some text, I wasn't sure if it contained just the name of the car (Kia) or Kia was in a sentence. I designed a formula that handles both.

GHIJKL
1
2
3ListCarColor
4My VW is pretty.VWGreen
5I own a Nissan.FiatAmber
6Land RoverBMWRed
7Jeeps are tough.Land RoverAmber
8FiatKiaGreen
9KiaSkodaAmber
10HondaRed
11JeepRed
12
13

<tbody>
</tbody>
Sheet8



The lookup table I have in K3:L11, and my list is in column H. Select column H, click Conditional Formatting > New Rule > Use a formula > and enter:
=SUMPRODUCT(--ISNUMBER(SEARCH($K$4:$K$11,H1)),--($L$4:$L$11="Green"))*(H1<>"")

Then click on Format... and pick a green fill color.

Repeat the steps twice more, changing Green to Amber and Red, and you'll get the layout as shown above.


Second option is to put this formula in I4:
=MATCH(INDEX($L$4:$L$11,MIN(IF(ISNUMBER(SEARCH($K$4:$K$11,H4)),ROW($K$4:$K$11)-ROW($K$4)+1))),{"Red","Amber","Green"},0)
confirm it with Control+Shift+Enter, and drag down.

Then select column I and pick the traffic lights icon set. You'll get the traffic lights in the next column. (The screen shot doesn't show the icons.)
Row 5, which has no match, gets green because green is the first color in L4:L11.

HIJKL
3ListCarColor
4My VW is pretty.3VWGreen
5I own a Nissan.3FiatAmber
6Land Rover2BMWRed
7Jeeps are tough.1Land RoverAmber
8Fiat2KiaGreen
9Kia3SkodaAmber
10HondaRed
11JeepRed
12

<tbody>
</tbody>
Sheet8
Let me know if either works for you.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,566
Members
449,089
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