How do I get Excel to return a value based on the max value in a table?

FSAEStudent

New Member
Joined
Aug 20, 2019
Messages
7
0 1 2 3 4 5
1 1 2 3 4 5
3 6 7 8 9 0
5 1 2 3 4 6
7 2 3 3 4 2

I have a table as such with rows and columns in bold. I know the max value within this table is 9. How can I get Excel to return "3" and "4"?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Code:
Sub FindMax()
    Dim Rng As Range, Val As Long, Loc As Range
    Set Rng = Range("A1:E7")
    Val = WorksheetFunction.Max(Rng)
    Set Loc = Rng.Find(what:=Val, LookIn:=xlValues)
    MsgBox "Maximum value found at row " & Loc.Row & ", column " & Loc.Column
End Sub
 
Upvote 0
With newer excel versions, perhaps this with wrapped text (array confirmed with Ctrl Shift Enter)

=TEXTJOIN(CHAR(10),1,IF($B$2:$F$5=MAX($B$2:$F$5),$A$2:$A$5&"&"&$B$1:$F$1,""))
 
Upvote 0
another way with Power Query

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]0[/td][td=bgcolor:#5B9BD5]1[/td][td=bgcolor:#5B9BD5]2[/td][td=bgcolor:#5B9BD5]3[/td][td=bgcolor:#5B9BD5]4[/td][td=bgcolor:#5B9BD5]5[/td][td][/td][td=bgcolor:#70AD47]Label[/td][td=bgcolor:#70AD47]Header[/td][td=bgcolor:#70AD47]Value[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]
2​
[/td][td=bgcolor:#DDEBF7]
3​
[/td][td=bgcolor:#DDEBF7]
4​
[/td][td=bgcolor:#DDEBF7]
5​
[/td][td][/td][td=bgcolor:#E2EFDA]
3​
[/td][td=bgcolor:#E2EFDA]
4​
[/td][td=bgcolor:#E2EFDA]
9​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
3​
[/td][td]
6​
[/td][td]
7​
[/td][td]
8​
[/td][td]
9​
[/td][td]
0​
[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
5​
[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]
2​
[/td][td=bgcolor:#DDEBF7]
3​
[/td][td=bgcolor:#DDEBF7]
4​
[/td][td=bgcolor:#DDEBF7]
6​
[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
7​
[/td][td]
2​
[/td][td]
3​
[/td][td]
3​
[/td][td]
4​
[/td][td]
2​
[/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Unpivot = Table.UnpivotOtherColumns(Source, {"0"}, "Attribute", "Value"),
    Type = Table.TransformColumnTypes(Unpivot,{{"0", Int64.Type}, {"Attribute", Int64.Type}, {"Value", Int64.Type}}),
    Filter = Table.SelectRows(Type, each ([Value] = List.Max(Type[Value]))),
    Rename = Table.RenameColumns(Filter,{{"0", "Label"}, {"Attribute", "Header"}})
in
    Rename[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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