# Formula to count Conditional Formats

#### midsession

##### Board Regular
Hello MrExcel

I'm trying to count cells affected by conditional formatting and I need help tidying up my efforts so far.

The numeric values in my table are highlighted if they exceed values in corresponding columns on other tables. The highlighting can be changed by the user changing the table to compare against. The logic for each cell runs something like this:

if cell is numeric
if column in (E, M, X, Y)
if (value < condition1 or > ccondition2)
highlight in blue
end
else ' columns not in (E, M, X, Y)
if (value > condition1 or < condition2)
highlight in red
end
end
end

My attempt to put together a formula for each cell appears to work, it looks like this for cell B3:
'=AND(ISNUMBER(\$B3),
OR(
AND(
OR(COLUMN()=5,COLUMN()=13,COLUMN()=24,COLUMN()=25),
OR(B3<VLOOKUP(\$B\$1, INDIRECT(\$A\$1), COLUMN(B3), FALSE),
\$B3>INDEX(INDIRECT(\$A\$1), MATCH(\$B\$1,INDIRECT(\$A\$1 & "I"),0)+ 2,COLUMN(B3)))),
AND(
NOT(OR(COLUMN()=5,COLUMN()=13,COLUMN()=24,COLUMN()=25)),
OR(\$B3>VLOOKUP(\$B\$1, INDIRECT(\$A\$1), COLUMN(\$B3), FALSE),
\$B3<INDEX(INDIRECT(\$A\$1), MATCH(\$B\$1,INDIRECT(\$A\$1 & "I"),0)+ 2,COLUMN(\$B3))))))

I can total the boolean values thus generated using '=COUNTIF(B21:AB21,TRUE)

But I do need a formula that will count highlighted cells for each row in the table. (I reckon I need either SUMPRODUCT, or an array formula using COUNTIF or COUNT(IF).

Can anyone help to tidy this formula?

### 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.

Replies
1
Views
113
Replies
24
Views
412
Replies
13
Views
249
Replies
15
Views
258
Replies
10
Views
195

1,181,891
Messages
5,932,665
Members
436,850
Latest member
Jasperlee93

### 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.

### Which adblocker are you using?

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

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