我有一个Excel文件,其中列A和列B都有数据,这些数据可能存在于其他列中,也可能不存在。我只对列A中不存在于列B中的数据感兴趣。这两个列具有相同的标题名称。我可以使用什么公式来显示哪些列A中的项目不在列B中?
我有一个Excel文件,其中列A和列B都有数据,这些数据可能存在于其他列中,也可能不存在。我只对列A中不存在于列B中的数据感兴趣。这两个列具有相同的标题名称。我可以使用什么公式来显示哪些列A中的项目不在列B中?
把这个放在C2单元格中,然后向下复制
=IF(ISNA(VLOOKUP(A2,$B$2:$B$65535,1,FALSE)),"not in B","")
如果 A 中的值不在 B 中,则列 C 中的单元格将显示 "not in B"。
Sub highlight_missings()
Dim i As Long, lastA As Long, lastB As Long
Dim compare As Variant
Range("A:A").ClearFormats
lastA = Range("A65536").End(xlUp).Row
lastB = Range("B65536").End(xlUp).Row
For i = 2 To lastA
compare = Application.Match(Range("a" & i), Range("B2:B" & lastB), 0)
If IsError(compare) Then
Range("A" & i).Interior.ColorIndex = 3
End If
Next i
End Sub