|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Dim arr, i&, dic As Object, rng As Range
Set dic = CreateObject("Scripting.Dictionary")
arr = Sheets(2).[a1].CurrentRegion
For i = 2 To UBound(arr)
If arr(i, 40) = "" Then
dic(arr(i, 3)) = ""
End If
Next i
arr = [b1].CurrentRegion
For i = 2 To UBound(arr)
If dic.exists(arr(i, 2)) Then
If Not rng Is Nothing Then
Set rng = Union(rng, Cells(i, 2).Resize(, 3))
Else
Set rng = Cells(i, 2).Resize(, 3)
End If
End If
Next i
If Not rng Is Nothing Then
Cells.Interior.ColorIndex = 0
rng.Interior.Color = vbRed
End If
Set dic = Nothing
Beep
End Sub |
|