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
| Sub classement_5equipe()
Dim Cel As Range
Dim club As String, club_ref As String, club_ref2 As String, club_ref3 As String, club_ref4 As String
Dim score_ref As Integer, score_max As Integer, score_min As Integer
' ==== Initialisation des variables
score_ref = 0
score_max = 0
score_min = 0
' ==== trouver le 1er du classement
For Each Cel In Range("C5:C9")
If Cel.Value > score_ref Then
score_ref = Cel.Value
club = Cel.Offset(0, -1)
End If
Next Cel
Range("D5") = club
Range("E5") = score_ref
' ==== trouver le 2eme du classement
score_min = 0
score_max = Range("E5").Value
club_ref = Range("D5").Value
For Each Cel In Range("C5:C9")
' ==== Boucle pour tenir compte d'une égalité
If Cel.Value = score_max Then
If Cel.Offset(0, -1).Value <> club_ref Then
Range("D6") = Cel.Offset(0, -1).Value
Range("E6") = Cel.Value
End If
' ==== Boucle si pas d'égalité
ElseIf (Cel.Value < score_max) And (Cel.Value > score_min) Then
If Cel.Value <> score_max Then
score_ref = Cel.Value
club = Cel.Offset(0, -1)
score_min = Cel.Value
End If
Range("D6") = club
Range("E6") = score_ref
End If
Next Cel
' ==== trouver le 3eme du classement
score_max = Range("E6").Value
club_ref = Range("D6").Value
club_ref2 = Range("D5").Value
score_min = 0
For Each Cel In Range("C5:C9")
If Cel.Value = score_max Then
If (Cel.Offset(0, -1).Value <> club_ref) And (Cel.Offset(0, -1).Value <> club_ref2) Then
Range("D7") = Cel.Offset(0, -1).Value
Range("E7") = Cel.Value
End If
ElseIf (Cel.Value < score_max) And (Cel.Value > score_min) Then
If Cel.Value <> score_max Then
score_ref = Cel.Value
club = Cel.Offset(0, -1)
score_min = Cel.Value
End If
Range("D7") = club
Range("E7") = score_ref
End If
Next Cel
' ==== trouver le 4eme du classement
score_max = Range("E7").Value
club_ref = Range("D6").Value
club_ref2 = Range("D5").Value
club_ref3 = Range("D7").Value
score_min = 0
For Each Cel In Range("C5:C9")
If Cel.Value = score_max Then
If (Cel.Offset(0, -1).Value <> club_ref) And (Cel.Offset(0, -1).Value <> club_ref2) And (Cel.Offset(0, -1).Value <> club_ref3) Then
Range("D8") = Cel.Offset(0, -1).Value
Range("E8") = Cel.Value
End If
ElseIf (Cel.Value < score_max) And (Cel.Value > score_min) Then
If Cel.Value <> score_max Then
score_ref = Cel.Value
club = Cel.Offset(0, -1)
score_min = Cel.Value
End If
Range("D8") = club
Range("E8") = score_ref
End If
Next Cel
' ==== trouver le 5eme du classement
score_max = Range("E8").Value
club_ref = Range("D6").Value
club_ref2 = Range("D5").Value
club_ref3 = Range("D7").Value
club_ref4 = Range("D8").Value
score_min = 0
For Each Cel In Range("C5:C9")
If Cel.Value = score_max Then
If (Cel.Offset(0, -1).Value <> club_ref) And (Cel.Offset(0, -1).Value <> club_ref2) And (Cel.Offset(0, -1).Value <> club_ref3) And (Cel.Offset(0, -1).Value <> club_ref4) Then
Range("D9") = Cel.Offset(0, -1).Value
Range("E9") = Cel.Value
End If
ElseIf (Cel.Value < score_max) And (Cel.Value > score_min) Then
If Cel.Value <> score_max Then
score_ref = Cel.Value
club = Cel.Offset(0, -1)
score_min = Cel.Value
End If
Range("D9") = club
Range("E9") = score_ref
End If
Next Cel
Range("B4").Select
End Sub |
Partager