简体   繁体   中英

EXCEL Get the column header of the lowest value in the row

With the help of teylyn's answer in my previous question, the lowest value in the row are successfully highlighted. How to get the column letter to be displayed in the last column?

FROM

在此输入图像描述

TO

在此输入图像描述

=Left(if($C4=Min($C4:$I4),$C$3&" & ","")&if($E4=Min($C4:$I4),$E$3&" & ","")&if($G4=Min($C4:$I4),$G$3&" & ","")&if($I4=Min($C4:$I4),$I$3&" & ",""),LEN(if($C4=Min($C4:$I4),$C$3&" & ","")&if($E4=Min($C4:$I4),$E$3&" & ","")&if($G4=Min($C4:$I4),$G$3&" & ","")&if($I4=Min($C4:$I4),$I$3&" & ",""))-3)

Its ugly...really ugly. But it does work. Put that monstrosity in J4 and copy down.

where to begin with the description, I thought ugly and monstrosity covered it! Basically what the whole formula is doing is checking each number in the row to detemine if it is the minimum in the row. When that condition is true, it returns the value in the header row for that number and tacks on a " & " to it. It then moves on to the next column and performs the same check and adds the results to the previous column. When a number is not the minimum it adds "" to the results which is nothing. After going through all the results and building up a string that will end in "&" we pull the left side of the string, by the length of the string minus 3 characters to remove that last " & ".

Proof of concept

概念证明

Like said in the comments of Forward Ed's answer, you could shorten the LEN -part with COUNTIF which would look like this:

=LEFT(IF($C4=MIN($C4:$I4),$C$3&" & ","")&IF($E4=MIN($C4:$I4),$E$3&" & ","")&IF($G4=MIN($C4:$I4),$G$3&" & ","")&IF($I4=MIN($C4:$I4),$I$3&" & ",""),COUNTIF($C4:$I4,MIN($C4:$I4))*4-3)

Still I would prefer the MID solution to (partially) skip any check of length like this:

=MID(IF($C4=MIN($C4:$I4)," & "&$C$3,"")&IF($E4=MIN($C4:$I4)," & "&$E$3,"")&IF($G4=MIN($C4:$I4)," & "&$G$3,"")&IF($I4=MIN($C4:$I4)," & "&$I$3,""),4,20)

The way it works should be pretty obvious. However, if there are any questions left, just ask :)

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