EDIT: Likely an easy question, basically I have three values, let's say 9, 4 and 7 in different cells (not in a table), I want to find the minimum in an order then return its relative position, for example: 9,4,7 would return 2 as 4 is the minimum and is positioned second.
What is the correct excel formula to do so? Thanks .
Solution: Thanks all for your help, I didn't think excel could do if it wasn't continuous. I've ended up using a series of nested IF statements, an AND statement and < signs, to get the job done :)
Here's an array formula that should work. It assumes the values are in A1, C3, and B4.
=MAX(IF(CHOOSE(TRANSPOSE({1,2,3}),$A$1,$C$3,$B$4)=MIN($A$1,$C$3,$B$4),TRANSPOSE({1,2,3}),0))
You can simply;
=ROUND(MIN(A1,B1,C1), 0)
Ah, after clarification;
I can't think of a way to do that with a formula, it can be done with VBA (Assumes all numeric cells + the highest index is returned in the result of a clash)
=OrdinalMin(A2,B2,C2)
//in a module
Public Function OrdinalMin(ParamArray cells() As Variant) As Long
Dim i As Long, min As Double
For i = 0 To UBound(cells)
If cells(i) <= cells(min) Then min = i
Next
OrdinalMin = min + 1
End Function
min: =MIN(A1,B2,C3)
position: =MATCH(2,1/FREQUENCY(min,(A1,B2,C3)))
Unfortunately, Excel lookup functions want continuos range of data.
For a set of random cells, use something like:
Public Function Match2(ByVal What As Variant, ByVal Where As Range) As Long
Dim a As Range
Dim c As Range
Dim g As Long
For Each a In Where.Areas
For Each c In a.Cells
g = g + 1
If c.Value = What Then
Match2 = g
Exit Function
End If
Next
Next
End Function
Usage:
=Match2(MIN(B6,F9,I16),(B6,F9,I16))
Array formula:
{=SUM((B$16:M$16)*(B23:M23=MIN(B23:M23)))}
where the range B$16:M$16
has the indices (i.e. 1, 2, 3, 4, etc), and B23:M23
has the values being considered.