Conditional formatting - based on a single cell lookup in a range

rfj1001

New Member
Joined
Apr 18, 2017
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I want to change the background colour of a column header (cell C2) to Green only if one of the cells in the column (C3-C12) has the character C in it. Any other characters, or more than one C, etc. should not change the colour.

Can SKS help out as I just can't seem to get a formula that works.

Version is Excel 365

Many thanks

Rob
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
What is SKS?

Do I understand correctly that you are looking for a cell that contains just "C" and nothing else? If so, your CF rule for C2 will be:

=COUNTIF(C3:C12,"C")>0
 
Upvote 0
Try using the following conditional formatting rule for green fill:

=COUNTIF(C3:C12,"*C*")=1
 
Upvote 0
Maybe try this in cell C2:

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">=SUMPRODUCT(--NOT(ISERROR(FIND("C",$C$3:$C$12))))</code>
 
Upvote 0
But that will not work if I have understood this correctly:

Hi AliGW and others,

Thanks for all the replies

=COUNTIF(C3:C12,"*C*")=1 will certainly pick up the character C in the selected range but, as you allude to, doesn’t handle the other part of what I’m trying to achieve ie “Any other characters or more than one C, etc. should not change the colour (of the output cell).”

It’s this second part of the formula I just can’t seem to get right.

SKS = Some Kind Soul <g><g></g></g>
 
Upvote 0
Hi AliGW and others,

Thanks for all the replies

=COUNTIF(C3:C12,"*C*")=1 will certainly pick up the character C in the selected range but, as you allude to, doesn’t handle the other part of what I’m trying to achieve ie “Any other characters or more than one C, etc. should not change the colour (of the output cell).”

It’s this second part of the formula I just can’t seem to get right.

SKS = Some Kind Soul <g><g></g></g>
Posting an example with the expected results could help exclude guesswork and get the right formula. As you can see, different people have understood your description quite differently.

To the best of my understanding, my formula from Post #3 does exactly what's been requested: it returns TRUE if only one cell in range C3:C12 has a "C" in it. If none of the cells has a "C" or if multiple cells have "C", the formula returns FALSE.

If your intention is to have the column header highlighted if there is only one "C" in only one cell, then try this:

=AND(COUNTIF(C3:C12,"*C*")=1,COUNTIF(C3:C12,"*C*C*")=0)

If it's something else, then try posting an example.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

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