VLOOKUP and MAX IF. Is this possible?

Boycopus

New Member
Joined
Sep 16, 2014
Messages
2
Hello. I hope somebody can help me on this one. I have been trying this for a day or so and looked up on google and this site to no luck.

I want to be able to run a VLOOKUP (or alternative) after creating a subset through MAXIF. Here is an example with some data. I can use the MAXIF function to tell me that 300 is the top score by an English competitor, and that 155 is the top score by a Spanish competitor but I want a formula that tells me that Alan is the top English competitor and that Charles is the top Spaniard, and that Greg is the top Frenchman.

A - B - C (A1:C8 Data Table)
Alan - 300 - England
Brian - 180 - England
Charles - 155 - Spain
Don - 200 - France
Edgar - 12 - Guinea
Francis - 13 - Spain
Greg - 210 - France
Harry - 222 - Haiti

Many thanks
BC

<TBODY>
</TBODY><COLGROUP><COL><COL><COL></COLGROUP>
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
if excel 2010 or later:


<b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">E4</th><td style="text-align:left">=LOOKUP(<font color="Blue">9.99999999999E+307,ROW(<font color="Red">B1:B8</font>)/(<font color="Red">(<font color="Green">C1:C8=E1</font>)*(<font color="Green">B1:B8=AGGREGATE(<font color="Purple">14,6,B1:B8/(<font color="Teal">C1:C8=E1</font>),1</font>)</font>)</font>),A1:A8</font>)</td></tr></tbody></table></td></tr></table><br />


Excel 2013
ABCDE
1Alan300EnglandFrance
2Brian180England
3Charles155Spain
4Don200FranceGreg
5Edgar12Guinea
6Francis13Spain
7Greg210France
8Harry222Haiti
Sheet3
 
Upvote 0
if excel 2010 or later:


Worksheet Formulas
CellFormula
E4=LOOKUP(9.99999999999E+307,ROW(B1:B8)/((C1:C8=E1)*(B1:B8=AGGREGATE(14,6,B1:B8/(C1:C8=E1),1))),A1:A8)

<tbody>
</tbody>



Excel 2013
ABCDE
1Alan300EnglandFrance
2Brian180England
3Charles155Spain
4Don200FranceGreg
5Edgar12Guinea
6Francis13Spain
7Greg210France
8Harry222Haiti

<tbody>
</tbody>
Sheet3


You could also do this with an array formula
(assuming the same setup as VBA Geek with some implied named ranges):
Code:
=INDEX($A$1:$C$8,MATCH(MAX(IF(country=$E$1,score,"")),score,0),1,1)
Enter with ctrl shift enter...not just enter

I often see this:
9.99999999999E+307
on the forum, but don't know what it means, would someone mind explaining

 
Upvote 0
yes but if possible i prefer to avoid CSE :)

9.99999999999e+307 is the biggest number excel understands, so the lookup function returns the last number in the array

Watch:
https://www.youtube.com/watch?v=N24cBM-CTw4



You could also do this with an array formula
(assuming the same setup as VBA Geek with some implied named ranges):
Code:
=INDEX($A$1:$C$8,MATCH(MAX(IF(country=$E$1,score,"")),score,0),1,1)
Enter with ctrl shift enter...not just enter

I often see this:
9.99999999999E+307
on the forum, but don't know what it means, would someone mind explaining

 
Upvote 0
You could also do this with an array formula
(assuming the same setup as VBA Geek with some implied named ranges):
Code:
=INDEX($A$1:$C$8,MATCH(MAX(IF(country=$E$1,score,"")),score,0),1,1)
Enter with ctrl shift enter...not just enter
[COLOR=#0000FF]

[/COLOR][/QUOTE]

Many thanks for the replies. I couldn't get the first one to work but this one using INDEX and MATCH got me close. The only problem I have is when I expand it to 2000 rows it starts to report erroneous data. Imagine that Harry also scores 210, then it reports that Haiti's top scorer is Greg because it is the first row with 210 in it. Any ideas how we can get over this ?

thanks
BC
 
Upvote 0
could you not get mine to work because you are using an earlier version of excel or because you are using excel 2010 (or later) but the formula has an error?
 
Upvote 0

Forum statistics

Threads
1,214,874
Messages
6,122,034
Members
449,061
Latest member
TheRealJoaquin

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