如果我在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中有什么公式。
而且,如果有两个或两个以上具有相同数据的人,所有请求的名称都可以出现在一个搜索结果中吗?
我应该使用什么公式来解决它?
答案 0 :(得分:0)
使用所谓的索引匹配。您可以使用&
https://exceljet.net/formula/index-and-match-with-multiple-criteria
答案 1 :(得分:0)
以下是一些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中,我添加了以下* index函数:
=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)