Read all suggestions in this thread
Avoid using merged cells.
I deleted the first row for that reason.
And applied this macro:
Sub snb()
sq = Cells(1, 1).CurrentRegion
sn = Cells(1, 5).CurrentRegion
For j = 2 To UBound(sq)
For jj = 2 To UBound(sn)
If sq(j, 2) = sn(jj, 3) Then
Cells(jj, 5).Resize(, 5).Interior.ColorIndex = IIf(sq(j, 3) = sn(jj, 4), 12, 10)
Cells(j, 1).Resize(, 3).Interior.ColorIndex = IIf(sq(j, 3) = sn(jj, 4), 12, 10)
Exit For
End If
Next
Next
End Sub
an alternative:
Sub tst2()
On Error Resume Next
sq = Cells(1, 1).CurrentRegion
For j = 2 To UBound(sq)
With Columns(7).Find(sq(j, 2)).Offset
If Err.Number = 0 Then
.Offset(, -2).Resize(, 5).Interior.ColorIndex = IIf(.Offset(, 1) = sq(j, 3), 14, 16)
Cells(j, 1).Resize(, 3).Interior.ColorIndex = IIf(.Offset(, 1) = sq(j, 3), 14, 16)
End If
Err.Clear
End With
Next
End Sub
Bookmarks