
Option Explicit
Public Sub controlla()
Dim rng As Range, cella As Range
Dim s As String, i As Integer
Dim somma_gol As Integer, v As Variant
[I6:I20].ClearContents
Set rng = [E6:E20]
For Each cella In rng
i = i + 1
'1-X-2
If cella.Offset(, 1) > cella.Offset(, 2) Then
s = "1"
ElseIf cella.Offset(, 1) = cella.Offset(, 2) Then
s = "X"
Else
s = "2"
End If
'gol - nogol
If cella.Offset(, 1) <> 0 And cella.Offset(, 2) <> 0 Then
s = s & " - gol"
ElseIf InStr(cella.Offset(, 1) & cella.Offset(, 2), "0") Then
s = s & " - nogol"
End If
'over e under
somma_gol = cella.Offset(, 1) + cella.Offset(, 2)
s = s & " - " & Choose(somma_gol, "under 1,5 ", "over 1,5 - under 2,5 ", "over 1,5 - over 2,5 - under 3,5 ", "over 1,5 - over 2,5 - over 3,5 ")
If somma_gol > 4 Then s = s & "over 1,5 - over 2,5 - over 3,5 "
'inserisce la traduzione dei risultati in colonna "esito calcolato"
cella.Offset(, 3) = s
'cella corrisponde a ESITO (pronostico) quindi controlla col risultato effettivo per dare un responso
cella.Offset(, 4) = IIf(InStr(UCase(s), cella & " "), "INDOVINATA", "SBAGLIATA")
'controllo suppletivo per le doppie chance
If Len(cella) = 2 Then
cella.Offset(, 4) = IIf(Left(s, 1) Like "[" & cella & "]", "INDOVINATA", "SBAGLIATA")
End If
Next
MsgBox "Fatto!"
End Sub
|
'over e under
somma_gol = cella.Offset(, 1) + cella.Offset(, 2)
s = s & " - " & Choose(somma_gol + 1, "under 1,5 ", "under 1,5 - under 2,5 - under 3,5 ", "under 2,5 - under 3,5 - over 1,5 ", "over 1,5 - over 2,5 - under 3,5 ")
If somma_gol >= 4 Then s = s & "over 1,5 - over 2,5 - over 3,5 "
|
'Gol è quando entrambe le squadre segnano mentre nogol quando almeno una squadra non segna; lo 0 a 0 è nogol
'gol - nogol
If cella.Offset(, 1) > 0 And cella.Offset(, 2) > 0 Then 'qui almeno una delle due squadre segna
s = s & " - gol"
ElseIf cella.Offset(, 1) = 0 Or cella.Offset(, 2) = 0 Then 'qui una delle due squadre non segna
s = s & " - nogol"
End If |
If cella.Offset(, 1) > 0 And cella.Offset(, 2) > 0 Then 'qui entrambe le squadre segnano almeno un gol |
Option Explicit
Public Sub controlla()
Dim rng As Range, cella As Range
Dim s As String, i As Integer
Dim somma_gol As Integer, v As Variant, ok As Boolean
[I6:I20].ClearContents
Set rng = [E6:E20]
For Each cella In rng
i = i + 1
'1-X-2
If cella.Offset(, 1) > cella.Offset(, 2) Then
s = "1"
ElseIf cella.Offset(, 1) = cella.Offset(, 2) Then
s = "X"
Else
s = "2"
End If
'gol - nogol
'Gol è quando entrambe le squadre segnano mentre nogol quando almeno una squadra non segna; lo 0 a 0 è nogol
'gol - nogol
If cella.Offset(, 1) > 0 And cella.Offset(, 2) > 0 Then 'qui almeno una delle due squadre segna
s = s & " - gol"
ElseIf cella.Offset(, 1) = 0 Or cella.Offset(, 2) = 0 Then 'qui una delle due squadre non segna
s = s & " - nogol"
End If
'over e under
somma_gol = cella.Offset(, 1) + cella.Offset(, 2)
s = s & " - " & Choose(somma_gol + 1, "under 1,5 - under 2,5 - under 3,5 ", "under 1,5 - under 2,5 - under 3,5 ", "under 2,5 - under 3,5 - over 1,5 ", "over 1,5 - over 2,5 - under 3,5 ")
If somma_gol >= 4 Then s = s & "over 1,5 - over 2,5 - over 3,5 "
'inserisce la traduzione dei risultati in colonna "esito calcolato"
cella.Offset(, 3) = s
'cella corrisponde a ESITO (pronostico) quindi controlla col risultato effettivo per dare un responso
'viene verificato ogni singolo item che di cui si compone il risultato effettivo.
For Each v In Split(s, "-")
ok = False
If LCase(cella) = Trim(v) Then
cella.Offset(, 4) = "INDOVINATA"
ok = True
Exit For
End If
Next
If Not ok Then cella.Offset(, 4) = "SBAGLIATA"
'controllo suppletivo per le doppie chance
If Len(cella) = 2 Then
cella.Offset(, 4) = IIf(Left(s, 1) Like "[" & cella & "]", "INDOVINATA", "SBAGLIATA")
End If
Next
If Cells(20, 10) = 0 Then
MsgBox "SCOMMESSA VINTA!"
Else
MsgBox "SCOMMESSA PERSA!"
End If
Range("A1").Select
End Sub
|
Option Explicit
Public Sub controlla()
Dim rng As Range, cella As Range
Dim s As String, i As Integer
Dim somma_gol As Integer, v As Variant, ok As Boolean
[I6:I20].ClearContents
Set rng = [E6:E20]
For Each cella In rng
i = i + 1
'1-X-2
If cella.Offset(, 1) > cella.Offset(, 2) Then
s = "1"
ElseIf cella.Offset(, 1) = cella.Offset(, 2) Then
s = "X"
Else
s = "2"
End If
'gol - nogol
'Gol è quando entrambe le squadre segnano mentre nogol quando almeno una squadra non segna; lo 0 a 0 è nogol
If cella.Offset(, 1) > 0 And cella.Offset(, 2) > 0 Then 'qui almeno una delle due squadre segna
s = s & " - gol"
ElseIf cella.Offset(, 1) = 0 Or cella.Offset(, 2) = 0 Then 'qui una delle due squadre non segna
s = s & " - nogol"
End If
'over e under
somma_gol = cella.Offset(, 1) + cella.Offset(, 2)
s = s & " - " & Choose(somma_gol + 1, "under 1,5 - under 2,5 - under 3,5 ", "under 1,5 - under 2,5 - under 3,5 ", "under 2,5 - under 3,5 - over 1,5 ", "over 1,5 - over 2,5 - under 3,5 ")
If somma_gol >= 4 Then s = s & "over 1,5 - over 2,5 - over 3,5 "
'inserisce la traduzione dei risultati in colonna "esito calcolato"
cella.Offset(, 3) = s
'cella corrisponde a ESITO (pronostico) quindi controlla col risultato effettivo per dare un responso
'viene verificato ogni singolo item che di cui si compone il risultato effettivo.
For Each v In Split(s, "-")
ok = False
If LCase(cella) = LCase(Trim(v)) Then '<--- confrontiamo come si deve!!
cella.Offset(, 4) = "INDOVINATA"
ok = True
Exit For
End If
Next
If Not ok Then cella.Offset(, 4) = "SBAGLIATA"
'controllo suppletivo per le doppie chance
If Len(cella) = 2 Then
cella.Offset(, 4) = IIf(Left(s, 1) Like "[" & cella & "]", "INDOVINATA", "SBAGLIATA")
End If
If Trim(cella) = "" Then cella.Offset(, 4) = "" ' <--- assenza di pronostico, cella vuota
Next
If Cells(20, 10) = 0 Then
MsgBox "SCOMMESSA VINTA!"
Else
MsgBox "SCOMMESSA PERSA!"
End If
Range("A1").Select
End Sub
|
