google-sheets - 编码索引匹配以搜索多个列
问题描述
我需要在多列中搜索一个数字,然后在另一个单元格中返回信息。这是一个示例表:
我想保留左边的名字和顶部的会议。其他名称和会议将在以后添加。
在单独的选项卡上,我使用以下功能:
=SMALL('100M'!B2:D5,1)
找出表格中最小的数字。我现在需要在表格中搜索上述函数的结果并返回此人的姓名。我知道索引/匹配:
=index('100M'!$A$2:$D$5,match($B$2,'100M'!$D$2:$D$5,0),1)
如果我指定确切的列,这将起作用。我需要搜索每一列以匹配小号,然后返回个人姓名。
解决方案
创建用户定义函数
Function GetMinName() As String
Dim dataRange As Range
Dim minValue As Double
Dim minValueCell As Range
' Define the data range
Set dataRange = Worksheets("Sheet1").Range("B2:D5")
' Find the minimum value in the data range
minValue = WorksheetFunction.min(dataRange)
' Find the first cell containing minimum value
Set minValueCell = dataRange.Find(minValue, LookIn:=xlValues)
' Return the name in col 1 of the row containing the min value.
GetMinName = Worksheets("Sheet1").Cells(minValueCell.Row, 1)
End Function
这是您在另一张纸上的单元格中输入的公式。
=GetMinName()
推荐阅读
- python - Python 'e' 符号
- javascript - 在 onload 函数中访问 DOM 元素
- laravel - 获取MAC地址PC和手机有区别吗?
- sql - REGEX_LIKE 到 ~*
- javascript - 是否可以在 setInterval 中运行函数?
- regex - 只允许数字并且可以“包含”斜线并且不能以斜线开头或结尾
- javascript - 如何在函数中对条件进行单元测试?
- reactjs - 从具有 nginx 大小限制的 react 应用程序上传文件
- php - PHP正则表达式匹配
- docker-compose - FileBeat 未将 docker-container 日志发送到 Elastic-search