如果我在excel中有这样的数据
Name || Fruit || things || element
David || Apple || pencil || wind
Ana || Banana || eraser || water
Calum || watermelon || pen || earth
Noah || kiwi || ruler || fire并且,我想找出谁在数据表中拥有与上面三个对象相同的对象。我想找出谁的名字。
Fruit || things || element
Banana || eraser || water可以肯定的是,出来的名字是"Ana“。但我不知道excel中的公式是什么。
而且,如果有2个或更多的人拥有相同的数据,那么所有请求的名称是否都可以出现在一个搜索结果中?
我应该用什么公式来解决它呢?
发布于 2019-02-06 04:26:13
这里有一些VBA可以帮你做到这一点:
Function multiLookup(lookup_value, value_array As range, lookup_array, Optional delim = ",", Optional error_val = "Error")
multiLookup = "<Not Found>"
On Error GoTo error
lookup_ct = UBound(lookup_array, 1) - LBound(lookup_array, 1) + 1
If lookup_ct <> value_array.Count Then GoTo error
For i = 1 To value_array.Count
Debug.Print value_array(i), lookup_array(i, 1)
If lookup_array(i, 1) = lookup_value Then
If multiLookup <> "" Then
If multiLookup = "<Not Found>" Then
multiLookup = ""
Else
multiLookup = multiLookup & delim & " "
End If
End If
multiLookup = multiLookup & value_array(i)
End If
Next i
On Error GoTo 0
Exit Function
error:
multiLookup = error_val
End Function使用下表(例如使用单元格A1:D6 ):
Name|Fruit|things|element
David|Apple|pencil|wind
Ana|Banana|eraser|water
Calum|watermelon|pen|earth
Noah|kiwi|ruler|fire
Tom|Banana|eraser|water然后我创建了一个输入(例如单元格B8:D8 ):
Banana|eraser|water在单元格索引中,我添加了以下* A8函数:
=multiLookup(B8&C8&D8,A1:A6,B1:B6&C1:C6&D1:D6)*索引函数必须使用Shift+Enter输入
这将返回Ana, Tom
文档
lookup_value: this is the target value (in this case Bananaeraserwater from B8:D8)
value_array: this is the label array (in this case the name column)
lookup_array: this is the concatenated data array (fruit col & things col & element col)
delim: Default is a comma, this is the mark that separates output values
error_val: Default is "Error" this is the function return value if there is an error (most likely value_array is not the same length as lookup_array)https://stackoverflow.com/questions/54523841
复制相似问题