Forum Discussion
Conditional Formatting - formula for adjacent cells
Hi again,
With this I'd suggest to use in conditional formatting not Cell value = rule, but formula rule which highlights the cell if the formula returns TRUE.
The formula is
=((ROW()-ROW($C2)+1)=
MATCH(
AGGREGATE(14,6,($C$2:$C$18)*
((ROW($C$2:$C$18)-ROW($C$2)+1)<>MATCH(LARGE($E$2:$E$9,OR(1,2,3)),$E$2:$E$9,0))*
((ROW($C$2:$C$18)-ROW($C$2)+1)<>COUNT($C$2:$C$11)+MATCH(LARGE($E$11:$E$18,OR(1,2,3)),$E$11:$E$18,0)),1),
$C2:$C$18,0)
)*
((ROW()-ROW($C$2)+1)<>MATCH(LARGE($E$2:$E$9,1),$E$2:$E$9,0))*
((ROW()-ROW($C$2)+1)<>MATCH(LARGE($E$2:$E$9,2),$E$2:$E$9,0))*
((ROW()-ROW($C$2)+1)<>MATCH(LARGE($E$2:$E$9,3),$E$2:$E$9,0))*
((ROW()-ROW($C$2)+1)<>COUNT($C$2:$C$11)+ MATCH(LARGE($E$11:$E$18,1),$E$11:$E$18,0))*
((ROW()-ROW($C$2)+1)<>COUNT($C$2:$C$11)+ MATCH(LARGE($E$11:$E$18,2),$E$11:$E$18,0))*
((ROW()-ROW($C$2)+1)<>COUNT($C$2:$C$11)+ MATCH(LARGE($E$11:$E$18,3),$E$11:$E$18,0))In first part we compare the current row number within the table with if it is equal to the row number of the first large value (returned by AGGREGATE) from ones which are not equal to largest three in second column (MATCH within AGGREGATE). Here we use OR(1,2,3) to compare three largest together. OR since conditional formatting doesn't allow array constants within the formula. On the other hand built-in array calculations within AGGREGATE correctly checks OR.
Next by AND conditions we check if received row number is not the same as row numbers for largest three in second column. Perhaps that part could be simplified, not sure right now.
Posted previous message and recognized what LARGE returns same value for second and first if they are equal, i.e
=LARGE({23,23,22},2)returns 23, not 22.
It looks like another correction is required for second and third largest, perhaps with COUNTIF. Some later...