Conditional formatting based on multiple columns

sobeitjedi

Board Regular
Joined
Mar 13, 2006
Messages
235
Office Version
  1. 365
Hi

In my sheet, columns a, b, c and d can contain either "yes" or "no" - the rest of the columns contain text

I want to colour the row red if any of abcd contains a no
I want to colour the row green only if all of abcd contain yes

I then want to count how many rows are coloured red
I then want to count how many rows are coloured green

Sounds simple, but I'm struggling - please help.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
put this CF in A1 and apply to all rows

<img src="https://www.pixelsbin.com/images/2019/07/16/Untitledbc6642699190a6c9.jpg" alt="Untitledbc6642699190a6c9.jpg" border="0">

and the countif() to count them


Book1
ABCD
1YesNoYesNo
2YesYesNoYes
3YesYesYesNo
4YesYesYesYes
5YesNoNoNo
6YesYesYesNo
7NoNoYesYes
8YesYesYesYes
9YesNoNoNo
10YesNoNoNo
11YesYesYesYes
12YesYesNoNo
13YesYesYesNo
14NoYesNoNo
15NoYesYesYes
16NoYesYesNo
17NoYesYesYes
18NoYesYesYes
19NoNoNoNo
20YesNoYesYes
21
22No of Yes48
23No of No32
Sheet1
Cell Formulas
RangeFormula
B22=COUNTIF($A$1:$D$20,"Yes")
B23=COUNTIF($A$1:$D$20,"No")
 
Upvote 0
Not quite ....

The conditional format for yes/green works, thank you
Using the same principle to colour red for no, only colours the rows that all abcd are no, not where a single no occurs

Also, the count formula is counting all cells where a yes or no occurs - I want the rows where either all abcd are a yes, or where abcd contains a no.
 
Upvote 0
Not quite ....

The conditional format for yes/green works, thank you
Using the same principle to colour red for no, only colours the rows that all abcd are no, not where a single no occurs

Also, the count formula is counting all cells where a yes or no occurs - I want the rows where either all abcd are a yes, or where abcd contains a no.

to highlight the No rows just change yes to no to the second CF formula, as for the No of 4 yes etc, it's easier with a helper column like this


Book1
ABCDE
1YesNoYesNo2
2YesYesNoYes3
3YesYesYesNo3
4YesYesYesYes4
5YesNoNoNo1
6YesYesYesNo3
7NoNoYesYes2
8YesYesYesYes4
9YesNoNoNo1
10YesNoNoNo1
11YesYesYesYes4
12YesYesNoNo2
13YesYesYesNo3
14NoYesNoNo1
15NoYesYesYes3
16NoYesYesNo2
17NoYesYesYes3
18NoYesYesYes3
19NoNoNoNo0
20YesNoYesYes3
21
22Yes3
23No1
Sheet1
Cell Formulas
RangeFormula
E1=COUNTIF(A1:D1,"Yes")
B22=COUNTIF($E$1:$E$20,4)
B23=COUNTIF($E$1:$E$20,0)
 
Last edited:
Upvote 0
Sorry, but you still don't understand - perhaps I'm not explaining well enough?

If I change the yes to a no in the second CF formula, using your table, it would only colour row 19. I want to colour the rows where a no occurs in any of abcd.

As for the count, in your table the yes is correct as there are 3 rows with all yes's. But the no count should equal 17 (rows where abcd contain a no) - would prefer to do this without a helper column, if possible?
 
Upvote 0
Sorry, but you still don't understand - perhaps I'm not explaining well enough?

If I change the yes to a no in the second CF formula, using your table, it would only colour row 19. I want to colour the rows where a no occurs in any of abcd.

ok, change the formula to =COUNTIF($A1:$D1,"No")>0

As for the count, in your table the yes is correct as there are 3 rows with all yes's. But the no count should equal 17 (rows where abcd contain a no) - would prefer to do this without a helper column, if possible?

a similar approach


Book1
ABCDE
1YesNoYesNo0
2YesYesNoYes0
3YesYesYesNo0
4YesYesYesYes1
5YesNoNoNo0
6YesYesYesNo0
7NoNoYesYes0
8YesYesYesYes1
9Yes
10YesNoNoNo0
11YesYesYesYes1
12YesYesNo0
13YesYesYesNo0
14NoYesNoNo0
15NoYesYesYes0
16NoYesYesNo0
17YesYesYes
18NoYesYesYes0
19NoNoNoNo0
20YesNoYesYes0
21
22Yes3
23No15
Sheet1
Cell Formulas
RangeFormula
E1=IF(ISNUMBER(MATCH("No",A1:D1,0)),0,IF(COUNTIF(A1:D1,"Yes")=4,1,""))
B22=COUNTIF($E$1:$E$20,1)
B23=COUNTIF($E$1:$E$20,0)
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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