Match and return highest value

justaddwater

New Member
Joined
Jun 3, 2019
Messages
3
Apologies for the newb question, im very much beginner level excel.
I'm trying to find a value in column A where there at least 2 of that same name and find the higher number of those two matched names. I also want to return the name of the agent that ties to the higher value in column C.
i.e. I want to look up Melbourne and the value should return 610, and in another column I want to return Robert.

SiteAgentValue
MelbournePenny585
Melbourne
<strike></strike>
Robert610
SydneyMichael1100
SydneyCourtney1150

<tbody>
</tbody>
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
If you place this array formula (CTRL+SHIFT+Enter) in column D, it will return the max for the match:

Code:
=MAX(IF($A$2:$A$5="Melbourne",$C$2:$C$5))

and this array formula in E2:

Code:
=INDEX($B$2:$B$5,MATCH(1,("Melbourne"=$A$2:$A$5)*(D2=$C$2:$C$5),0))

If you drag those two down 1 row and change the name to "Sydney"
 
Last edited:
Upvote 0
If you place this array formula (CTRL+SHIFT+Enter) in column D, it will return the max for the match:

Code:
=MAX(IF(A2:A5="Melbourne",C2:C5))

and this array formula in E2:

Code:
=INDEX(B2:B5,MATCH(1,("Melbourne"=A2:A5)*(D2=C2:C5),0))

Thanks kweaver, that will definitely work, but I have 180 different sites, so instead of having to include the site name in the formula, I wanted to be able to look it up from the table, and then find the highest corresponding value. Is it possible to combine a vlookup in the formula to do this?
 
Upvote 0
Try this


<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:50.38px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:78.89px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="background-color:#ffc000; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Site</td><td style="background-color:#ffc000; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Agent</td><td style="background-color:#ffc000; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Value</td><td style="color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; "> </td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Site</td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Name</td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Value</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Melbourne</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Penny</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">585</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#222222; font-family:Verdana; font-size:9pt; text-align:left; ">Melbourne</td><td >Robert</td><td style="text-align:right; ">610</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="color:#222222; font-family:Verdana; font-size:9pt; text-align:left; ">Melbourne</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Robert</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">610</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Sydney</td><td >Courtney</td><td style="text-align:right; ">1150</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Sydney</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Michael</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">1100</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Perth</td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Sydney</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Courtney</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">1150</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Perth</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Math</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">200</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >F2</td><td >=IFERROR(INDEX($B$2:$B$6,MATCH(G2,$C$2:$C$6,0)),"")</td></tr><tr><td >G2</td><td >{=IFERROR(MAX(IF(COUNTIF($A$2:$A$6,E2)>1,IF($A$2:$A$6=E2,$C$2:$C$6,),#N/A)),"")}</td></tr></table></td></tr></table>


In cell G2 is array formula

Array formulas
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself
 
Upvote 0
Thanks for your help gents. How do I get it to find the smaller of the numbers. If I replace the MAX formula with MIN, it returns zero.
 
Upvote 0
Thanks for your help gents. How do I get it to find the smaller of the numbers. If I replace the MAX formula with MIN, it returns zero.

Try this

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:50.38px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:78.89px;" /><col style="width:76.04px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td><td >H</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="background-color:#ffc000; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Site</td><td style="background-color:#ffc000; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Agent</td><td style="background-color:#ffc000; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Value</td><td style="color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; "> </td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Site</td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Name</td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Max</td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Min</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Melbourne</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Penny</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">585</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#222222; font-family:Verdana; font-size:9pt; text-align:left; ">Melbourne</td><td >Robert</td><td style="text-align:right; ">610</td><td style="text-align:right; ">585</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="color:#222222; font-family:Verdana; font-size:9pt; text-align:left; ">Melbourne</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Robert</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">610</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Sydney</td><td >Courtney</td><td style="text-align:right; ">1150</td><td style="text-align:right; ">1100</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Sydney</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Michael</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">1100</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Perth</td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Sydney</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Courtney</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">1150</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Perth</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Math</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">200</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td > </td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Array formula</td></tr><tr><td >F2</td><td >=IFERROR(INDEX($B$2:$B$6,MATCH(G2,$C$2:$C$6,0)),"")</td></tr><tr><td >G2</td><td >{=IFERROR(MAX(IF(SUM(($A$2:$A$6=$E2)*1)>1,IF($A$2:$A$6=$E2,$C$2:$C$6),#N/A)),"")}</td></tr><tr><td >H2</td><td >{=IFERROR(MIN(IF(SUM(($A$2:$A$6=$E2)*1)>1,IF($A$2:$A$6=$E2,$C$2:$C$6),#N/A)),"")}</td></tr></table></td></tr></table>
 
Upvote 0
If you should have duplicate numbers for max and min values at two different sites then Dante's formula for agent name will only return the first name (see column F below).
If you could have duplicates then try formulas in I2 and J2 in the example below.
Excel Workbook
ABCDEFGHIJ
1SiteAgentValueSiteNameMaxValueMin ValueMax NameMin Name
2MelbournePenny585MelbourneRobert610585RobertPenny
3MelbourneRobert610SydneyRobert610585CourtneyMichael
4SydneyMichael585Perth
5SydneyCourtney610
6PerthMath200
Sheet
 
Upvote 0
I guess you also need the name of the minimum value, then

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:50.38px;" /><col style="width:76.04px;" /><col style="width:96px;" /><col style="width:78.89px;" /><col style="width:91.25px;" /><col style="width:76.04px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td><td >H</td><td >I</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="background-color:#ffc000; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Site</td><td style="background-color:#ffc000; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Agent</td><td style="background-color:#ffc000; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Value</td><td style="color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; "> </td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Site</td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Name Max</td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Max</td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Name Min</td><td style="background-color:#92d050; color:#333333; font-weight:bold; font-family:Verdana; font-size:9pt; ">Min</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Melbourne</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Penny</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">585</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#222222; font-family:Verdana; font-size:9pt; text-align:left; ">Melbourne</td><td >Robert</td><td style="text-align:right; ">610</td><td >Penny</td><td style="text-align:right; ">585</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="color:#222222; font-family:Verdana; font-size:9pt; text-align:left; ">Melbourne</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Robert</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">610</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Sydney</td><td >Courtney</td><td style="text-align:right; ">1150</td><td >Michael</td><td style="text-align:right; ">1100</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Sydney</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Michael</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">1100</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Perth</td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Sydney</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Courtney</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">1150</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Perth</td><td style="color:#333333; font-family:Verdana; font-size:9pt; ">Math</td><td style="color:#333333; font-family:Verdana; font-size:9pt; text-align:right; ">200</td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td style="color:#333333; font-family:Verdana; font-size:9pt; "> </td><td > </td><td > </td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >F2</td><td >=IFERROR(INDEX($B$2:$B$6,MATCH(G2,$C$2:$C$6,0)),"")</td></tr><tr><td >G2</td><td >{=IFERROR(MAX(IF(SUM(($A$2:$A$6=$E2)*1)>1,IF($A$2:$A$6=$E2,$C$2:$C$6),#N/A)),"")}</td></tr><tr><td >H2</td><td >=IFERROR(INDEX($B$2:$B$6,MATCH(I2,$C$2:$C$6,0)),"")</td></tr><tr><td >I2</td><td >{=IFERROR(MIN(IF(SUM(($A$2:$A$6=$E2)*1)>1,IF($A$2:$A$6=$E2,$C$2:$C$6),#N/A)),"")}</td></tr></table></td></tr></table>
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,541
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top