简体   繁体   中英

Conditional Formatting with Filtering - How to highlight the cell with the MIN value of a caculation based on the result of two other cells

Conditional Formatting - How to highlight the cell with the minimum value based on the result of two other cells. I want to highlight the cell in selected cells in a Row that corresponds to the smallest product in the each column. (Note all value in the rows will be equal to or greater than zero)

Example: Imagine Cells A1:E2 are all filled with numbers, with at least one cell equalling to zero. Here Cells A2, C2, or E2 can be highlighted. Cell E2 is highlighted as E1 E2 is the smallest non-zero product out of the products A1 A2, C1 C2, E1 E2

So far I have used the formula

=A$1 A$2=MIN($A$1 $A$2,$C$1*$C$2,$E$1*$E$2) applied to A2,C2,E2

Excel 2021

Can more than 1 of the 3 fields be = 0? If only 1 or none = 0, then this works. I've formatted it for clarity since there are multiple nested if's.

=A1*A2=IF(  $A$1*$A$2=0, 
            MIN($C$1*$C$2,$E$1*$E$2), 
            IF(  $C$1*$C$2=0, 
                 MIN($A$1*$A$2,$E$1*$E$2), 
                 IF(   $E$1*$E$2=0, 
                       MIN($A$1*$A$2,$C$1*$C$2),
                       MIN($A$1*$A$2,$C$1*$C$2,$E$1*$E$2)
                  ) 
            )
        )

OK, so what you need to do logically is to exclude any 0 values from the MIN calculation. You can do that by testing each product, and if 0, change it to a number larger than any possible normal value (I used 9999). This works:

=A1*A2=MIN(
    IF($A$1*$A$2=0,9999, $A$1*$A$2),
    IF($C$1*$C$2=0,9999, $C$1*$C$2),
    IF($E$1*$E$2=0,9999, $E$1*$E$2))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM