
Option Explicit
Sub somma90()
Dim i As Long
Dim o As Long
Range("C6:V20000").Interior.ColorIndex = xlNone
Range("X6:AF20000").ClearContents
For i = 6 To Cells(Rows.Count, 1).End(xlUp).Row
For o = 0 To 4 ''prime 5
If Cells(i, 3 + o) + Cells(i, 8 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 3 + o).Interior.ColorIndex = 3
Cells(i, 8 + o).Interior.ColorIndex = 3
End If
If Cells(i, 3 + o) + Cells(i, 13 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 3 + o).Interior.ColorIndex = 3
Cells(i, 13 + o).Interior.ColorIndex = 3
End If
If Cells(i, 3 + o) + Cells(i, 18 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 3 + o).Interior.ColorIndex = 3
Cells(i, 18 + o).Interior.ColorIndex = 3
End If
If Cells(i, 8 + o) + Cells(i, 13 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 8 + o).Interior.ColorIndex = 3
Cells(i, 13 + o).Interior.ColorIndex = 3
End If
If Cells(i, 8 + o) + Cells(i, 18 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 8 + o).Interior.ColorIndex = 3
Cells(i, 18 + o).Interior.ColorIndex = 3
End If
If Cells(i, 13 + o) + Cells(i, 18 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 13 + o).Interior.ColorIndex = 3
Cells(i, 18 + o).Interior.ColorIndex = 3
End If
Next o
'''''''''''''''''''666
If Cells(i, 3) + Cells(i, 9) = 90 Then
Cells(i, 29) = 90
Cells(i, 3).Interior.ColorIndex = 3
Cells(i, 9).Interior.ColorIndex = 3
End If
If Cells(i, 3) + Cells(i, 15) = 90 Then
Cells(i, 29) = 90
Cells(i, 3).Interior.ColorIndex = 3
Cells(i, 15).Interior.ColorIndex = 3
End If
If Cells(i, 3) + Cells(i, 21) = 90 Then
Cells(i, 29) = 90
Cells(i, 3).Interior.ColorIndex = 3
Cells(i, 21).Interior.ColorIndex = 3
End If
If Cells(i, 9) + Cells(i, 15) = 90 Then
Cells(i, 29) = 90
Cells(i, 9).Interior.ColorIndex = 3
Cells(i, 15).Interior.ColorIndex = 3
End If
If Cells(i, 9) + Cells(i, 21) = 90 Then
Cells(i, 29) = 90
Cells(i, 9).Interior.ColorIndex = 3
Cells(i, 21).Interior.ColorIndex = 3
End If
If Cells(i, 15) + Cells(i, 21) = 90 Then
Cells(i, 29) = 90
Cells(i, 15).Interior.ColorIndex = 3
Cells(i, 21).Interior.ColorIndex = 3
End If
'''''''''''''777
If Cells(i, 4) + Cells(i, 10) = 90 Then
Cells(i, 30) = 90
Cells(i, 4).Interior.ColorIndex = 3
Cells(i, 10).Interior.ColorIndex = 3
End If
If Cells(i, 4) + Cells(i, 16) = 90 Then
Cells(i, 30) = 90
Cells(i, 4).Interior.ColorIndex = 3
Cells(i, 16).Interior.ColorIndex = 3
End If
If Cells(i, 4) + Cells(i, 22) = 90 Then
Cells(i, 30) = 90
Cells(i, 4).Interior.ColorIndex = 3
Cells(i, 22).Interior.ColorIndex = 3
End If
If Cells(i, 10) + Cells(i, 16) = 90 Then
Cells(i, 30) = 90
Cells(i, 10).Interior.ColorIndex = 3
Cells(i, 16).Interior.ColorIndex = 3
End If
If Cells(i, 10) + Cells(i, 22) = 90 Then
Cells(i, 30) = 90
Cells(i, 10).Interior.ColorIndex = 3
Cells(i, 22).Interior.ColorIndex = 3
End If
If Cells(i, 16) + Cells(i, 22) = 90 Then
Cells(i, 30) = 90
Cells(i, 16).Interior.ColorIndex = 3
Cells(i, 22).Interior.ColorIndex = 3
End If
''''''''''''''''''88888
If Cells(i, 6) + Cells(i, 10) = 90 Then
Cells(i, 31) = 90
Cells(i, 6).Interior.ColorIndex = 3
Cells(i, 10).Interior.ColorIndex = 3
End If
If Cells(i, 6) + Cells(i, 14) = 90 Then
Cells(i, 31) = 90
Cells(i, 6).Interior.ColorIndex = 3
Cells(i, 14).Interior.ColorIndex = 3
End If
If Cells(i, 6) + Cells(i, 18) = 90 Then
Cells(i, 31) = 90
Cells(i, 6).Interior.ColorIndex = 3
Cells(i, 18).Interior.ColorIndex = 3
End If
If Cells(i, 10) + Cells(i, 14) = 90 Then
Cells(i, 31) = 90
Cells(i, 10).Interior.ColorIndex = 3
Cells(i, 14).Interior.ColorIndex = 3
End If
If Cells(i, 10) + Cells(i, 18) = 90 Then
Cells(i, 31) = 90
Cells(i, 10).Interior.ColorIndex = 3
Cells(i, 18).Interior.ColorIndex = 3
End If
If Cells(i, 14) + Cells(i, 18) = 90 Then
Cells(i, 31) = 90
Cells(i, 14).Interior.ColorIndex = 3
Cells(i, 18).Interior.ColorIndex = 3
End If
''''''''''' 9999999999
If Cells(i, 7) + Cells(i, 11) = 90 Then
Cells(i, 32) = 90
Cells(i, 7).Interior.ColorIndex = 3
Cells(i, 11).Interior.ColorIndex = 3
End If
If Cells(i, 7) + Cells(i, 17) = 90 Then
Cells(i, 32) = 90
Cells(i, 7).Interior.ColorIndex = 3
Cells(i, 17).Interior.ColorIndex = 3
End If
If Cells(i, 6) + Cells(i, 19) = 90 Then
Cells(i, 32) = 90
Cells(i, 6).Interior.ColorIndex = 3
Cells(i, 19).Interior.ColorIndex = 3
End If
If Cells(i, 11) + Cells(i, 17) = 90 Then
Cells(i, 32) = 90
Cells(i, 11).Interior.ColorIndex = 3
Cells(i, 17).Interior.ColorIndex = 3
End If
If Cells(i, 11) + Cells(i, 19) = 90 Then
Cells(i, 32) = 90
Cells(i, 11).Interior.ColorIndex = 3
Cells(i, 19).Interior.ColorIndex = 3
End If
If Cells(i, 17) + Cells(i, 19) = 90 Then
Cells(i, 32) = 90
Cells(i, 17).Interior.ColorIndex = 3
Cells(i, 19).Interior.ColorIndex = 3
End If
Next i
End Sub
|
If Cells(i, 3 + o) + Cells(i, 8 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 3 + o).Interior.ColorIndex = 3
Cells(i, 8 + o).Interior.ColorIndex = 3
End If
If Cells(i, 3 + o) + Cells(i, 13 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 3 + o).Interior.ColorIndex = 4
Cells(i, 13 + o).Interior.ColorIndex = 4
End If
If Cells(i, 3 + o) + Cells(i, 18 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 3 + o).Interior.ColorIndex = 5
Cells(i, 18 + o).Interior.ColorIndex = 5
End If
... eccetera... |
''modifica al primo for , il resto al nostro amico
Range("C6:V20000").Interior.ColorIndex = xlNone
Range("X6:V20000").Interior.ColorIndex = xlNone
Range("X6:AF20000").ClearContents
For i = 6 To Cells(Rows.Count, 1).End(xlUp).Row
For o = 0 To 4 ''prime 5
If Cells(i, 3 + o) + Cells(i, 8 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 24 + o).Interior.ColorIndex = 3
Cells(i, 3 + o).Interior.ColorIndex = 3
Cells(i, 8 + o).Interior.ColorIndex = 3
End If
If Cells(i, 3 + o) + Cells(i, 13 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 24 + o).Interior.ColorIndex = 4
Cells(i, 3 + o).Interior.ColorIndex = 4
Cells(i, 13 + o).Interior.ColorIndex = 4
End If
If Cells(i, 3 + o) + Cells(i, 18 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 24 + o).Interior.ColorIndex = 5
Cells(i, 3 + o).Interior.ColorIndex = 5
Cells(i, 18 + o).Interior.ColorIndex = 5
End If
If Cells(i, 8 + o) + Cells(i, 13 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 24 + o).Interior.ColorIndex = 6
Cells(i, 8 + o).Interior.ColorIndex = 6
Cells(i, 13 + o).Interior.ColorIndex = 6
End If
If Cells(i, 8 + o) + Cells(i, 18 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 24 + o).Interior.ColorIndex = 7
Cells(i, 8 + o).Interior.ColorIndex = 7
Cells(i, 18 + o).Interior.ColorIndex = 7
End If
If Cells(i, 13 + o) + Cells(i, 18 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 24 + o).Interior.ColorIndex = 8
Cells(i, 13 + o).Interior.ColorIndex = 8
Cells(i, 18 + o).Interior.ColorIndex = 8
End If
Next o
|
For o = 0 To 4 ''prime 5
If Cells(i, 3 + o) + Cells(i, 8 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 3 + o).Interior.ColorIndex = 3
Cells(i, 8 + o).Interior.ColorIndex = 3
'questa parte seguente si ripete uguale
Cells(i, 34 + o) = Cells(i, 3 + o) & "_" & Cells(i, 8 + o) & "_" & Cells(i, 13 + o) & "_" & Cells(i, 18 + o)
End If
If Cells(i, 3 + o) + Cells(i, 13 + o) = 90 Then
Cells(i, 24 + o) = 90
Cells(i, 3 + o).Interior.ColorIndex = 4
Cells(i, 13 + o).Interior.ColorIndex = 4
Cells(i, 34 + o) = Cells(i, 3 + o) & "_" & Cells(i, 8 + o) & "_" & Cells(i, 13 + o) & "_" & Cells(i, 18 + o)
End If
... per le righe successive occorre più attenzione |
Option Explicit
Sub somma90_VF()
Dim xRow As Long
Dim i As Long
Dim j As Long
Dim m As Variant
Dim mask(1 To 9) As String
Dim col1 As String, col2 As String
Dim pos As Integer
Dim s As String
Dim tmp As Integer
Dim k As Integer
Dim COLORS As Variant
COLORS = Array(vbRed, vbYellow, vbGreen, vbCyan)
For i = 24 To 32 ' [X:AF]
mask(i - 23) = Join(Application.Transpose(Range(Cells(1, i), Cells(4, i))), vbNullString)
Next
Range("C6:V20000").Interior.ColorIndex = xlNone
Range("X6:AH20000").ClearContents
For xRow = 6 To Cells(Rows.Count, 1).End(xlUp).Row
For Each m In mask
For i = 1 To 3
For j = i + 1 To 4
col1 = Mid(m, i, 1)
col2 = Mid(m, j, 1)
If Cells(xRow, col1) + Cells(xRow, col2) = 90 Then
Cells(xRow, col1).Interior.Color = COLORS(k)
Cells(xRow, col2).Interior.Color = COLORS(k)
k = k + 1
If k = 4 Then k = 0
pos = Application.Match(m, mask, False)
Cells(xRow, 23 + pos) = 90
s = ""
For tmp = 1 To 4
s = s & Cells(xRow, Mid(mask(pos), tmp, 1)) & "_"
Next
s = Left(s, Len(s) - 1)
Cells(xRow, 33 + pos) = s
End If
Next
Next
Next
Next
End Sub
|
