2016-06-25 75 views
1

我有成百上千的记录,我只想在Excel中找到非重复值。从列A我想要超过列C中的值不等于B.有人可以帮助我一样。非重复值复制粘贴

A | B | C 
-------|-------|------- 
    1 | 4 | 1 
    2 | 5 | 2 
    3 | 6 | 3 
    4 | 7 | 13 
    5 | 8 | 14 
    6 | 9 | 15 
    7 | 10 | 
    8 | 11 | 
    9 | 12 | 
    10 | 16 | 
    11 | 17 | 
    12 |  | 
    13 |  | 
    14 |  | 
    15 |  | 
    16 |  | 
    17 |  | 

我已经用C粘贴我的价值观,并把这个公式B中列well..But这是不是有些细胞后的工作尝试。

=IF(ISERROR(MATCH(A1,$C$1:$C$10000,0)),"",A1) 

回答

0

使用辅助柱说Column E(变化E列的需要)有一个解决方法您的问题。

Cell E2写以下公式:

=IFERROR(INDEX($A$2:$A$20, MATCH(0,INDEX(COUNTIF(E1:$E$1, $A$2:$A$20)+(COUNTIF($A$2:$A$20, $A$2:$A$20)<>1),0,0), 0)),"") 

然后拖/根据需要复制下来这个公式。这会给你从Column A非重复的号码。

然后在Cell C2输入以下公式:

=IFERROR(INDEX($E$2:$E$20,MATCH(0,IFERROR(MATCH($E$2:$E$20,$B$2:$B$12,0),COUNTIF($C$1:$C1,$E$2:$E$20)),0)),"") 

这是阵列式所以通过按压Ctrl键 + 移位提交它 + 输入,并根据需要拖/向下复制此公式和你会得到你想要的结果,如下图所示:

enter image description here

编辑: VBA解决方案 ________________________________________________________________________________

Sub Demo() 
    Dim dict1 As Object, dict2 As Object, dict3 As Object 
    Dim c1 As Variant, c2 As Variant 
    Dim i As Long, lastRow As Long 

    Set dict1 = CreateObject("Scripting.Dictionary") 
    Set dict2 = CreateObject("Scripting.Dictionary") 
    Set dict3 = CreateObject("Scripting.Dictionary") 

    lastRow = Cells(Rows.count, "A").End(xlUp).Row '-->get last row of Column A 
    c1 = Range("A2:A" & lastRow) 
    'add unique values in Column A to dict1 
    For i = 1 To UBound(c1, 1) 
     dict1(c1(i, 1)) = 1 
    Next i 

    lastRow = Cells(Rows.count, "B").End(xlUp).Row '-->get last row of Column B 
    c2 = Range("B2:B" & lastRow) 
    'add unique values in Column B to dict2 
    For i = 1 To UBound(c2, 1) 
     dict2(c2(i, 1)) = 1 
    Next i 

    'check existence of dict1 values in dict2 
    'if not present add to dict3 
    For Each k In dict1.keys 
     If Not dict2.exists(k) Then 
      dict3.Add k, 1 
     End If 
    Next k 

    'display dict3 in Column C 
    Range("C2").Resize(dict3.count) = Application.Transpose(dict3.keys) 
End Sub 
+0

您好,感谢这个,我尝试了100条记录它很好地工作,我觉得这个公式可以是少量的记录有帮助。因为我面临同样的问题,因为我只有1500行,所以我花了很多时间,因为我有超过10万条记录,所以可能无法工作。是否有任何VBA代码,以便我们可以避免该公式,并可以使其快速并可以得到结果。或者可能在sql中。非常感谢。 –

+0

@RakeshGupta - 我已经添加了一个VBA解决方案。 – Mrig