Excel formula position of minimum value

こ雲淡風輕ζ 提交于 2019-12-31 05:10:19

问题


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 :)


回答1:


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))




回答2:


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



回答3:


min: =MIN(A1,B2,C3)

position: =MATCH(2,1/FREQUENCY(min,(A1,B2,C3)))




回答4:


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))



回答5:


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.



来源:https://stackoverflow.com/questions/6029749/excel-formula-position-of-minimum-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!