用于确定由 max 函数返回的同一行中的另一个单元格值的单元格函数 (excel)
Cell function for determining another cell value in the same row returned by max function (excel)
我真的不知道怎么通过google问这个,所以我就在这里做一个描述。
我正在使用 excel,我有一个 table 这样的
Pushups
A B C
6/16/2016 45 35
6/17/2016 47 37
etc...
每日基本俯卧撑文件。我知道如何度过我的 "best" 一天...
=max(B2:...)
=max(C2:...)
如何以编程方式获取最佳日期的日期?本质上,我需要能够获取 Max 选择的行的索引,然后从另一列...A 列中获取值。因此,无论最大值是多少,我都需要一个公式来从列中获取值同排A.
我觉得应该是个简单的,就是知识不够excel。
使用下面的代码(将 B 列 修改为您要查找最大值的任何列)
Option Explicit
Sub Date_of_Max()
Dim Row_Max As Long
Dim Rng As Range
' modify your range here to whatever Column you want
Set Rng = Range("B1:B" & Cells(Rows.Count, "B").End(xlUp).Row)
Row_Max = WorksheetFunction.Index(Rng, WorksheetFunction.Match(WorksheetFunction.Max(Rng), Rng, 0)).Row
MsgBox Range("A" & Row_Max)
End Sub
=INDEX(A1:A4,MATCH(MAX(B1:B4),B1:B4,0))
或
=INDEX(A1:A4;MATCH(MAX(B1:B4);B1:B4;0))
取决于 Excel 版本和本地化
我真的不知道怎么通过google问这个,所以我就在这里做一个描述。
我正在使用 excel,我有一个 table 这样的
Pushups
A B C
6/16/2016 45 35
6/17/2016 47 37
etc...
每日基本俯卧撑文件。我知道如何度过我的 "best" 一天...
=max(B2:...)
=max(C2:...)
如何以编程方式获取最佳日期的日期?本质上,我需要能够获取 Max 选择的行的索引,然后从另一列...A 列中获取值。因此,无论最大值是多少,我都需要一个公式来从列中获取值同排A.
我觉得应该是个简单的,就是知识不够excel。
使用下面的代码(将 B 列 修改为您要查找最大值的任何列)
Option Explicit
Sub Date_of_Max()
Dim Row_Max As Long
Dim Rng As Range
' modify your range here to whatever Column you want
Set Rng = Range("B1:B" & Cells(Rows.Count, "B").End(xlUp).Row)
Row_Max = WorksheetFunction.Index(Rng, WorksheetFunction.Match(WorksheetFunction.Max(Rng), Rng, 0)).Row
MsgBox Range("A" & Row_Max)
End Sub
=INDEX(A1:A4,MATCH(MAX(B1:B4),B1:B4,0))
或
=INDEX(A1:A4;MATCH(MAX(B1:B4);B1:B4;0))
取决于 Excel 版本和本地化