|
Sub test()
Set d = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
For Each sh In Sheets
sh.Select
d.RemoveAll
r = sh.Cells(Rows.Count, 1).End(3).Row
If r > 2 Then
arr = sh.[a1].CurrentRegion
For j = 2 To UBound(arr)
If Not d.exists(j) Then
For i = j + 1 To UBound(arr)
If arr(j, 2) = arr(i, 2) And Not d.exists(i) Then
If Len(arr(j, 5)) > 0 Then
If arr(j, 5) + arr(i, 5) = 0 Or arr(j, 5) - arr(i, 4) = 0 Then
Cells(j, 2).Resize(1, 5).Interior.ColorIndex = 7
Cells(i, 2).Resize(1, 5).Interior.ColorIndex = 7
d(i) = ""
End If
Else
If arr(j, 4) + arr(i, 4) = 0 Or arr(j, 4) - arr(i, 5) = 0 Then
Cells(j, 2).Resize(1, 5).Interior.ColorIndex = 7
Cells(i, 2).Resize(1, 5).Interior.ColorIndex = 7
d(i) = ""
End If
End If
End If
Next i
End If
Next j
End If
Next sh
Application.ScreenUpdating = True
End Sub
|
|