Excel匹配function

我的工作表有两个栏目cloumn Acolumn B cloumn AColumn A具有名称列表, column B具有其对应的值。

列表( Column A )中的某些项目具有重复项, column B具有不同的值。

我想要做的是删除column A中的重复,并且只有一个,其中所有对应的值在一个单元格中。 例:

 Colmn A Column B Column A Column B Apple 7 Apple 7, 1 Orange 2 will be Orange 2 Apple 1 

我使用下面的公式,但它给了我一个#NAME? 错误。

 =IF(MATCH(A2,A:A,0), contenate(B:B)) 

有人能告诉我我做错了什么吗?

这个短的macros将把结果放在DE列中:

 Sub Macro1() Dim M As Long, N As Long, rc As Long Dim i As Long, j As Long, v As String rc = Rows.Count Columns("A:A").Copy Columns("D:D") Range("D:D").RemoveDuplicates Columns:=1, Header:=xlNo M = Cells(rc, 1).End(xlUp).Row N = Cells(rc, 4).End(xlUp).Row For i = 1 To N v = Cells(i, 4) For j = 1 To M If Cells(j, 1) = v Then If Cells(i, 5) = "" Then Cells(i, 5) = Cells(j, 2) Else Cells(i, 5) = Cells(i, 5) & "," & Cells(j, 2) End If End If Next j Next i End Sub 

例如:

在这里输入图像说明