Max function

dave8

Active Member
Joined
Jul 8, 2007
Messages
275
I have a worksheet with the following data:


Column A Column B
John 60
Ann 80
Joe 50
John 75
Pete 95
Ann 75
Joe 65



I want to be able to get the highest (or Lowest) score in Column B, based on the Name in Column A. For example, I want the highest score for John. In this case, would be 75. Is there a Max function or something similar to get this?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
=SUMPRODUCT(LARGE((A:A="John")*(B:B),1))

reg formula


then you could change the 1 to a 2 to see who what John's second highest score was... and so on
 
Last edited:
Upvote 0
Excel Workbook
ABCDEF
14NameSomethingNameMaxMin
15John60John7560
16Ann80Ann8075
17Joe50Joe6550
18John75Pete9595
19Pete95
20Ann75
21Joe65
Sheet


Note that F15 is array-entered (Formula Array above). Then copy the formulae down.
 
Upvote 0
Thanks for this tip. Okay, how to translate into VBA? I need to somehow be able to get different scores by changing only the name and not have to redo the formula.
 
Upvote 0
Thanks for this tip. Okay, how to translate into VBA? I need to somehow be able to get different scores by changing only the name and not have to redo the formula.
vba?! just change the name in any of the rows in my offering, delete the other rows. No formula change required at all.
 
Upvote 0
I can't get it to work. This works in VBA:

Selection.FormulaArray = "=Max(IF(B2:B16=""Web Training"",E2:E16))"

But this doesn't work:

' Selection.FormulaArray = "'=Max(IF(B2" & ":B" & num & " = " & "" & "Web Training" & "" & "))"


I'm trying to built the formula by plugging in variables. The name, "Web Training", I want to be able to assign a name. Can you help me with this?
 
Upvote 0
I've found that, when building formulas, its easier to build range variables and then use .Address than it is to parse the address in the formula creation

Code:
Dim BcolumnRange as Range
Dim searchTerm as String

Set BcolumnRange = Range("B2:B16")
searchTerm = "Web Training"

Selection.FormulaArray = "= MAX(IF(" & BcolumnRange.Address(false,false) & "=" & Chr(34) & searchTerm & chr(34) & "," & BcolumnRange.Offset(0, 3).Address(false,false) & "))"
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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