Search code examples
excelexcel-formulavlookup

Find MAX and MIN using Excel VLOOKUP by matching the Rows and Results the matching First Column


1st Sheet

1st Sem 2nd Sem 3rd Sem 4th Sem
MATHS 10 20 30 15
ENGLISH 20 35 5 15

Result

2nd Sheet

Tried to get the result (second picture). Looked for an answer and only got answers which results the marks but not first column matching the mark. Can anyone please help.


Solution

  • In older Excel: =INDEX($B$1:$E$1,MATCH(MAX(B2:E2),B2:E2,0)) Or =LOOKUP(MAX(B2:E2),B2:E2,$B$1:$E$1)

    In case you need it to deal with ties: =TEXTJOIN(", ",,REPT($B$1:$E$1,B2:E2=MAX(B2:E2))) (Not sure it requires being entered with ctrl+shift+enter)

    And replace MAX by MIN for min header.

    Using Office 365: =@SORTBY($B$1:$E$1,B2:E2,-1)

    And remove ,-1 for min header.