1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
|
Sub Classement()
'Cette macro calcule, à partir des pronostics établis, le classement par groupe des équipes
'Ensuite elle insère dans une autre feuille les pronostics en question pour les comparer ensuite aux résultats réels
'pasligne va de 11 en 11, et permet de faire les calculs pour les groupes A à F
'ligne1 parcourt le tableau de gauche
'ligne2 parcourt le tableau de droite
'les deux tableaux sont des listes, dans lesquelles on va aller chercher les noms de pays et leur nombre de points
'les autres variables calculent les points, les buts marqués ou encaissés, etc etc...
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''' INITIALISATION DES VARIABLES '''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Liste des pays
'On peut ainsi parcourir la liste de tous les pays pour y entrer les différents points via le compteur plus loin
Dim GroupS(24) As String
GroupS(0) = "France"
GroupS(1) = "Albanie"
GroupS(2) = "Roumanie"
GroupS(3) = "Suisse"
GroupS(4) = "Angleterre"
GroupS(5) = "Pays de Galles"
GroupS(6) = "Russie"
GroupS(7) = "Slovaquie"
GroupS(8) = "Allemagne"
GroupS(9) = "Pologne"
GroupS(10) = "Ukraine"
GroupS(11) = "Irlande du Nord"
GroupS(12) = "Espagne"
GroupS(13) = "Turquie"
GroupS(14) = "Rép. Tchèque"
GroupS(15) = "Croatie"
GroupS(16) = "Belgique"
GroupS(17) = "Irlande"
GroupS(18) = "Italie"
GroupS(19) = "Suède"
GroupS(20) = "Portugal"
GroupS(21) = "Autriche"
GroupS(22) = "Islande"
GroupS(23) = "Hongrie"
'Liste des compteurs de points par pays
Dim GroupC(24) As Integer
GroupC(0) = 0
GroupC(1) = 0
GroupC(2) = 0
GroupC(3) = 0
GroupC(4) = 0
GroupC(5) = 0
GroupC(6) = 0
GroupC(7) = 0
GroupC(8) = 0
GroupC(9) = 0
GroupC(10) = 0
GroupC(11) = 0
GroupC(12) = 0
GroupC(13) = 0
GroupC(14) = 0
GroupC(15) = 0
GroupC(16) = 0
GroupC(17) = 0
GroupC(18) = 0
GroupC(19) = 0
GroupC(20) = 0
GroupC(21) = 0
GroupC(22) = 0
GroupC(23) = 0
'Pour les boucles
Dim i As Integer
Dim ligne1 As Integer
Dim ligne2 As Integer
Dim pasligne As Integer
'Pour les intitulés des colonnes
Dim Paysgauche As Integer
Paysgauche = 2
Dim Paysdroite As Integer
Paysdroite = 8
Dim PTS As Integer
PTS = 9
Dim G As Integer
G = 11
Dim N As Integer
N = 12
Dim P As Integer
P = 13
Dim Bplus As Integer
Bplus = 14
Dim Bmoins As Integer
Bmoins = 15
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''' Avant de faire quoi que ce soit, on remet les cellules à 0 ''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For pasligne = 9 To 64 Step 11
With Sheets("Poules")
'Nombre de points
Cells(pasligne + 1, PTS).Value = 0
Cells(pasligne + 2, PTS).Value = 0
Cells(pasligne + 3, PTS).Value = 0
Cells(pasligne + 4, PTS).Value = 0
'Nombre de matchs gagnés, nuls ou perdus
Cells(pasligne + 1, G).Value = 0
Cells(pasligne + 2, G).Value = 0
Cells(pasligne + 3, G).Value = 0
Cells(pasligne + 4, G).Value = 0
Cells(pasligne + 1, N).Value = 0
Cells(pasligne + 2, N).Value = 0
Cells(pasligne + 3, N).Value = 0
Cells(pasligne + 4, N).Value = 0
Cells(pasligne + 1, P).Value = 0
Cells(pasligne + 2, P).Value = 0
Cells(pasligne + 3, P).Value = 0
Cells(pasligne + 4, P).Value = 0
'Nombre de buts marqués et de buts encaissés
Cells(pasligne + 1, Bplus).Value = 0
Cells(pasligne + 2, Bplus).Value = 0
Cells(pasligne + 3, Bplus).Value = 0
Cells(pasligne + 4, Bplus).Value = 0
Cells(pasligne + 1, Bmoins).Value = 0
Cells(pasligne + 2, Bmoins).Value = 0
Cells(pasligne + 3, Bmoins).Value = 0
Cells(pasligne + 4, Bmoins).Value = 0
'Pour pays à gauche
For ligne1 = pasligne To pasligne + 5
For i = 0 To 23
If Cells(ligne1, Paysgauche).Value = GroupS(i) And Cells(ligne1, Paysgauche + 1).Value > Cells(ligne1, Paysgauche + 2).Value Then
GroupC(i) = GroupC(i) + 3
End If
If Cells(ligne1, Paysgauche).Value = GroupS(i) And Cells(ligne1, Paysgauche + 1).Value = Cells(ligne1, Paysgauche + 2).Value Then
GroupC(i) = GroupC(i) + 1
End If
If Cells(ligne1, Paysgauche).Value = GroupS(i) And Cells(ligne1, Paysgauche + 1).Value < Cells(ligne1, Paysgauche + 2).Value Then
GroupC(i) = GroupC(i) + 0
End If
Next i
Next ligne1
'Pour pays à droite
For ligne1 = pasligne To pasligne + 5
For i = 0 To 23
If Cells(ligne1, Paysgauche + 3).Value = GroupS(i) And Cells(ligne1, Paysgauche + 1).Value < Cells(ligne1, Paysgauche + 2).Value Then
GroupC(i) = GroupC(i) + 3
End If
If Cells(ligne1, Paysgauche + 3).Value = GroupS(i) And Cells(ligne1, Paysgauche + 1).Value = Cells(ligne1, Paysgauche + 2).Value Then
GroupC(i) = GroupC(i) + 1
End If
If Cells(ligne1, Paysgauche + 3).Value = GroupS(i) And Cells(ligne1, Paysgauche + 1).Value > Cells(ligne1, Paysgauche + 2).Value Then
GroupC(i) = GroupC(i) + 0
End If
Next i
Next ligne1
'On entre le nombre de points dans le tableau
For ligne2 = pasligne + 1 To pasligne + 4
For i = 0 To 23
If Cells(ligne2, Paysdroite).Value = GroupS(i) Then
Cells(ligne2, PTS).Value = GroupC(i)
End If
Next i
Next ligne2
'Nombre de matchs gagnés, nuls ou perdus
For ligne1 = pasligne To pasligne + 5
For ligne2 = pasligne + 1 To pasligne + 4
'Gagné pour colonne de gauche
If Cells(ligne1, Paysgauche).Value = Cells(ligne2, Paysdroite).Value And Cells(ligne1, Paysgauche + 1).Value > Cells(ligne1, Paysgauche + 2).Value Then
Cells(ligne2, G).Value = Cells(ligne2, G).Value + 1
End If
'Nul pour colonne de gauche
If Cells(ligne1, Paysgauche).Value = Cells(ligne2, Paysdroite).Value And Cells(ligne1, Paysgauche + 1).Value = Cells(ligne1, Paysgauche + 2).Value Then
Cells(ligne2, N).Value = Cells(ligne2, N).Value + 1
End If
'Perdu pour colonne de gauche
If Cells(ligne1, Paysgauche).Value = Cells(ligne2, Paysdroite).Value And Cells(ligne1, Paysgauche + 1).Value < Cells(ligne1, Paysgauche + 2).Value Then
Cells(ligne2, P).Value = Cells(ligne2, P).Value + 1
End If
'Gagné pour colonne de droite
If Cells(ligne1, Paysgauche + 3).Value = Cells(ligne2, Paysdroite).Value And Cells(ligne1, Paysgauche + 1).Value < Cells(ligne1, Paysgauche + 2).Value Then
Cells(ligne2, G).Value = Cells(ligne2, G).Value + 1
End If
'Nul pour colonne de droite
If Cells(ligne1, Paysgauche + 3).Value = Cells(ligne2, Paysdroite).Value And Cells(ligne1, Paysgauche + 1).Value = Cells(ligne1, Paysgauche + 2).Value Then
Cells(ligne2, N).Value = Cells(ligne2, N).Value + 1
End If
'Perdu pour colonne de droite
If Cells(ligne1, Paysgauche + 3).Value = Cells(ligne2, Paysdroite).Value And Cells(ligne1, Paysgauche + 1).Value > Cells(ligne1, Paysgauche + 2).Value Then
Cells(ligne2, P).Value = Cells(ligne2, P).Value + 1
End If
Next ligne2
Next ligne1
'Nombre de buts marqués et de buts encaissés
For ligne1 = pasligne To pasligne + 5
For ligne2 = pasligne + 1 To pasligne + 4
If Cells(ligne1, Paysgauche).Value = Cells(ligne2, Paysdroite).Value Then
Cells(ligne2, Bplus).Value = Cells(ligne2, Bplus).Value + Cells(ligne1, Paysgauche + 1).Value
Cells(ligne2, Bmoins).Value = Cells(ligne2, Bmoins).Value + Cells(ligne1, Paysgauche + 2).Value
End If
If Cells(ligne1, Paysgauche + 3).Value = Cells(ligne2, Paysdroite).Value Then
Cells(ligne2, Bplus).Value = Cells(ligne2, Bplus).Value + Cells(ligne1, Paysgauche + 2).Value
Cells(ligne2, Bmoins).Value = Cells(ligne2, Bmoins).Value + Cells(ligne1, Paysgauche + 1).Value
End If
Next ligne2
Next ligne1
'On trie ensuite chaque tableau du 1er au dernier du groupe
Dim MaPlage As Object
Set MaPlage = Range("H" & pasligne & ":P" & pasligne + 4)
Dim MaPlage2 As Object
Set MaPlage2 = Range("I" & pasligne)
Dim MaPlage3 As Object
Set MaPlage3 = Range("P" & pasligne)
With Sheets("Feuil3")
MaPlage.Select
Selection.Sort Key1:=MaPlage2, Order1:=xlDescending, Key2:=MaPlage3 _
, Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom
End With
Next pasligne
End Sub |
Partager