midsession
Board Regular
- Joined
- Oct 12, 2006
- Messages
- 70
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?
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?