
Originally Posted by
ahmedleo414
I need to figure out a way to calculate the best bowling figure, Most wickets taken with least number of runs
In this case the best figure would be from Match 3, and the result would be 32-3
Hi,
Try This
IF YOU ARE USING OFFICE 365 NO NEED TO PRESS CTRL + SHIFT + ENTER OTHERWISE AFTER ENTERING FORMULA PRESS CTRL + SHIFT + ENTER
=SMALL(IF(E2:E21=MAX(E2:E21),$D$2:$D$21,""),1)&"-"&MAX(E2:E21)
Code for UDF
Function BBI(wkts_range As Range, runs_range As Range) As String
Dim runs_array As Variant
ReDim runs_array(1 To wkts_range.Count)
maxwkt = Application.WorksheetFunction.Max(wkts_range)
Row = 1
For i = 1 To wkts_range.Count
If wkts_range.Cells(i, 1) = maxwkt Then
runs_array(Row) = runs_range.Cells(i, 1)
Row = Row + 1
End If
Next i
minruns = Application.WorksheetFunction.Min(runs_array)
BBI = minruns & "-" & maxwkt
End Function
Code:
Function BBI(wkts_range As Range, runs_range As Range) As String
Dim runs_array As Variant
ReDim runs_array(1 To wkts_range.Count)
maxwkt = Application.WorksheetFunction.Max(wkts_range)
Row = 1
For i = 1 To wkts_range.Count
If wkts_range.Cells(i, 1) = maxwkt Then
runs_array(Row) = runs_range.Cells(i, 1)
Row = Row + 1
End If
Next i
minruns = Application.WorksheetFunction.Min(runs_array)
BBI = minruns & "-" & maxwkt
End Function
=bbi(E2:E21,D2:D21)
Bookmarks