![](/img/trans.png)
[英]Excel: Return multiple matches in a single cell while doing a partial match
[英]Excel: Check for partial matches from column against single cell
我在Excel中有兩列:
Column A
Row 1 Apple
Row 2 Blueberry
Row 3 Strawberry
Column B
Row 1 App
Row 2 Application
Row 3 Appendage
我想使用B列查看其中的任何單元格是否存在於A列的給定單元格中。到目前為止,我已經使用了VLOOKUP
和MATCH
函數,但我似乎都無法正常工作,但是MATCH
似乎成為我應該使用的那個。 我嘗試在列B上使用通配符,它返回值錯誤。 這是我所擁有的:
=MATCH(A1,"*"&B:B&"*",0)
非常感謝您的幫助!
有一個自然的VBA解決方案。 在標准代碼模塊中:
Function PartialMatch(v As Variant, R As Range) As Variant
Dim i As Long
For i = 1 To R.Cells.Count
If v Like "*" & R.Cells(i).Value & "*" Then
PartialMatch = i
Exit Function
End If
Next i
PartialMatch = CVErr(xlErrNA)
End Function
然后,您可以在電子表格中的所需位置使用以下公式:
=PartialMatch(A1,B:B)
如果存在部分匹配項,它將給出第一個部分匹配項的索引;如果不存在,則給出#N/A
請注意,空白單元格被視為部分匹配項,因此您可能需要確保傳遞函數的范圍不包含空格(因此請不要傳遞整個列)。 或重新定義部分匹配的意思。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.