我想在 vba 中创建一个 Excel 函数,其工作方式与 VLOOKUP 相同,但有一个额外的参数让您选择第 n 个唯一结果。
这是迄今为止我想出的非工作代码。它不起作用,而且有点不完整,但我想你可以看到我要去的地方。
Function MVLOOKUP(lookup_value, table_array As Range, col_index_num As Long, entry_num As Long, Optional range_lookup As Boolean) As Variant
'===========================
'Purpose: VLOOKUP but it finds ALL the matching entries, not just the first one.
'returns the entry you want by its number, starting at one
'entry_num is the entry to return
'most of this copied from top answer on this stackoverflow entry
'/sf/ask/1447338231/
Dim FoundCell As Range
Dim LastCell As Range
Dim …
Run Code Online (Sandbox Code Playgroud)