Sub 对比()
Dim i%, j%
arr1 = [A1:A100] '这是需要填色的范围,请自行调整
arr2 = [B1:B100] '这是条件范围,请自行调整
For i = 1 To UBound(arr1)
For j = 1 To UBound(arr2)
If arr2(j, 1) = arr1(i, 1) And arr2(j, 1) <> "" Then
'如果单元格内容相等且单元格内容不为空时。
Cells(i, "A").Interior.Color = RGB(255, 0, 0) '填红色
End If
Next j
Next i
End Sub
代码功能:以B列为条件,再A列查找,符合就填红色。