vba 如何在excel é中找到值的行索引
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1989628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I find the index of a row for a value in excel é
提问by excel34
is there a function in excel which can find the index of the row for a particular value é
excel中是否有一个函数可以找到特定值é的行索引
ie if I write function(5.77) it will return 5 , because 5.77 appears in row 5 .
即如果我写 function(5.77) 它将返回 5 ,因为 5.77 出现在第 5 行。
'1 Frequency '2 4.14 '3 4.19 '4 5.17 '5 5.77 '6 6.39
'1 频率 '2 4.14 '3 4.19 '4 5.17 '5 5.77 '6 6.39
回答by Adam Ralph
You can use the MATCH() worksheet function. In order to use this in VBA, you need to use the WorksheetFunction object, which exposes a subset of the Excel worksheet functions. E.g.
您可以使用 MATCH() 工作表函数。为了在 VBA 中使用它,您需要使用 WorksheetFunction 对象,该对象公开 Excel 工作表函数的子集。例如
Dim rowIndex as Long
rowIndex = WorksheetFunction.Match(5.77, Range(A1:A6))
回答by Aviad P.
The function is called MATCH
. It doesn't return the row number, but it returns the index of the cell inside the range, you can add the base row number to that to get the actual row number.
该函数被调用MATCH
。它不返回行号,但返回范围内单元格的索引,您可以将基本行号添加到该行号以获取实际行号。
PS. This is an excel function used in cell formulas, not an excel-vba function...
附注。这是单元格公式中使用的excel函数,而不是excel-vba函数...
回答by Kumarapush
Range.Find & Lookup are other good option to get the Row number of search string.
Range.Find & Lookup 是获取搜索字符串行数的其他不错的选择。