Sub calcola() Dim x, y, w, tot tot = Cells(6, 11) Range("D8:I18").Interior.ColorIndex = xlNone For x = 5 To 9 For y = 8 To 18 For w = 9 To 18 If Cells(y, x) + Cells(w, x) = tot Then Cells(y, x).Interior.ColorIndex = 4 Cells(w, x).Interior.ColorIndex = 4 End If Next Next Next End Sub
Option Explicit Sub xxxx() Dim col As Long, i As Long, o As Long Dim valK6 As Long Dim I1 As Long valK6 = Range("K6").Value Range("D8:I18").Interior.ColorIndex = xlNone For col = 5 To 9 For i = 8 To 18 I1 = Cells(i, col).Value For o = i + 1 To 18 If I1 + Cells(o, col).Value = valK6 Then Cells(i, col).Interior.ColorIndex = 4 Cells(o, col).Interior.ColorIndex = 4 Exit For End If Next o If I1 + Cells(o, col).Value = valK6 Then Exit For Next i Next col End Sub
Sub calcolacorretta2() Dim x, y, w, tot tot = Cells(6, 11) Range("E8:I18").Interior.ColorIndex = xlNone For x = 8 To 18 For y = 5 To 8 For w = y + 1 To 9 If Cells(x, y) + Cells(x, w) = tot Then Cells(x, y).Interior.ColorIndex = 4 Cells(x, w).Interior.ColorIndex = 4 End If Next Next Next End Sub