简体   繁体   English

Excel-搜索匹配值

[英]Excel - Search for Match Value

May I know how to search for a match value and only display one time only? 我可以知道如何搜索匹配值并且仅显示一次吗? For example: 例如:

A         B          C (will search for match and display one only)                                 
GHI      2          XXY        
XXY      3          
XXY      5   

I am able to output the match value but it will also display the duplicate value. 我可以输出匹配值,但它还会显示重复值。 For example, XXY will display twice in column C. Here is the code that I did 例如, XXY将在列C中显示两次。这是我所做的代码

=INDEX($A$1:$A$10,MATCH($A1,$A$1:$A$10,))

If you are using Excel 2016 use CONCAT formula with IF. 如果您使用的是Excel 2016,则将CONCAT公式与IF一起使用。 IF you are using earlier version you need to create UDF. 如果使用的是较早版本,则需要创建UDF。 as below 如下

Function ConcatUDF(Rng() As Variant, ByVal delim As String) As String
Dim a, I As Long
For I = 1 To UBound(Rng, 1)
    If Rng(I, 1) <> "" Then
    ConcatUDF = ConcatUDF & _
        IIf(ConcatUDF = "", "", delim) & Rng(I, 1)
    End If
Next
End Function

Here are the examples to use it. 这里是使用它的示例。 在此处输入图片说明 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM