如果我有这样的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
可以肯定,说出来的名字是“安娜”。但我不知道是什么公式在Excel这一点。
而且,如果有2个或更多的人谁具有相同的数据,可以将所有的请求的名字出现在一个搜索结果?
我应该使用什么公式来解决呢?
使用什么所谓的指数匹配。您可以连接具有&
输入
https://exceljet.net/formula/index-and-match-with-multiple-criteria
下面是一些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)
*指数函数必须具有换挡输入+ 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)