Sub coppiole()
Dim rng As Range
Set rng = ActiveSheet.Range("C5:V5")
Dim x As String, y As String, x1 As String, y1 As String
rng.Interior.ColorIndex = 0
For r1 = 5 to 150 '<<<<
c1 = 3
c2 = 4
c1c = 8
c2c = 9
ciclo = 4
For Each c In rng
If c2c > 22 Then
ciclo = ciclo - 1
If ciclo = 0 Then Exit For
c1c = c1c + 1
c2c = c1c + 1
End If
x = Cells(r1, c1) & Cells(r1, c2)
y = Cells(r1, c2) & Cells(r1, c1)
x1 = Cells(r1, c1c) & Cells(r1, c2c)
y1 = Cells(r1, c2c) & Cells(r1, c1c)
If x = x1 Or x = y1 Or y = x1 Or y = y1 Then
Cells(r1, c2c).Interior.ColorIndex = 3
Cells(r1, c1c).Interior.ColorIndex = 3
End If
c2c = c2c + 1
Next
Next r1 '<<<<
End Sub |