找到遗漏的单词并显示它

时间:2015-09-26 12:21:25

标签: excel

我需要知道一些编程代码来解决以下问题:

  1. 我在Sheet1中有十个名字,在Sheet2中有九个名字。
  2. 与Sheet1相比,如何编写代码来搜索Sheet2中缺少哪个名称,并在与Sheet1进行比较后显示Sheet2中缺少的名称?
  3. 我试过了:

    Dim i, j As Integer
    Dim EID(1 To 5) As Integer
    For i = 1 To 5
    EID(i) = Range("A" & i).Value
    Next i
    
    For i = 1 To 5
    If Not ActiveSheet.Cells.Find(EID(i)) Is Nothing Then
    MsgBox "Missing Number is" & EID(i)
    Next i
    

1 个答案:

答案 0 :(得分:0)

如果两个列表都在ColumnA中进行了标记和排序,则在Sheet2的B2中向下复制以适应:

=IF(ISNUMBER(MATCH(Sheet1!A$2:A$11,A$2:A$10,0)),"",INDEX(Sheet1!A$2:A$11,MATCH(A2,Sheet1!A$2:A$11,0)-1))