1

我正在尝试查找单元格中每个值的 ID。我尝试使用 VLOOKUP 但当单元格具有多个值时它会失败。

在这种情况下,B2 将更新为 4,1

在此处输入图像描述

在此处输入图像描述

4

2 回答 2

4

带有 IF 的 TEXTJOIN:

=TEXTJOIN(",",TRUE,IF(ISNUMBER(SEARCH(","&SUBSTITUTE('Item Details'!$A$2:$A$6," ","")&",",","&SUBSTITUTE(A2," ","")&",")),'Item Details'!$B$2:$B$6,""))

这将按查找表顺序对输出进行排序

在此处输入图像描述

另一种选择是使用 XLOOKUP:

=TEXTJOIN(",",TRUE,XLOOKUP(FILTERXML("<a><b>"&SUBSTITUTE(A2,",","</b><b>")&"</b></a>","//b"),'Item Details'!A:A,'Item Details'!B:B,"",0))

使用 Office 365,它将按输入排序。

在此处输入图像描述

于 2020-10-07T16:38:33.377 回答
1

试试这个小的用户定义函数:

Public Function zlookup(v As Variant, rng As Range) As String
    Dim a, arr, r As Range
    
    arr = Split(v, ",")
    For Each a In arr
        Set r = rng.Columns(1).Find(What:=a)
        zlookup = zlookup & "," & r.Offset(0, 1).Value
    Next a
    zlookup = Mid(zlookup, 2)
End Function

在此处输入图像描述

于 2020-10-07T16:51:47.040 回答