利用Excel宏实现A列与B列对比,标注不在B列中的数据,方便快捷地进行数据比对。只需要将以下代码复制到宏中执行即可:

Sub CompareColumns()

Dim LastRow As Long

Dim i As Long

Dim val As Variant

LastRow = Range("A" & Rows.Count).End(xlUp).Row

For i = 2 To LastRow

val = Cells(i, 1).Value

If IsError(Application.Match(val, Range("B:B"), 0)) Then

Cells(i, 3) = "不在B列中"

End If

Next i

End Sub