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
| Sub Recherche_Equipe()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set f1 = Sheets("Classement détaillé matchs qual")
Set f2 = Sheets("Résultats matchs qualif")
'***********************************************************************************
'Formule de recherche des doublons
'Poule A
f1_DerLig_A = f1.[B5].End(xlDown).Row
f1.Range("H5:H10").FormulaR1C1 = "=IF(COUNTIF(R5C3:R10C3,RC3)=2,RC2,"""")"
'Poule B
f1_DerLig_B = f1.[B19].End(xlDown).Row
f1.Range("H19:H24").FormulaR1C1 = "=IF(COUNTIF(R19C3:R24C3,RC3)=2,RC2,"""")"
f1.Range("H5:H24").Value = f1.Range("H5:H24").Value
'***********************************************************************************
'Traitement poule A
If Application.WorksheetFunction.CountA(f1.Range("H5:H" & f1_DerLig_A).Value) <> 0 Then
For i = 5 To f1_DerLig_A
If f1.Cells(i, "H") <> "" Then
Equipe1 = f1.Cells(i, "B")
Equipe2 = f1.Cells(i + 1, "B")
'***********************************************************************************
'Formule de recherche des 2 équipes en doublon
'Poule A
Formule = "=IF(OR(AND(RC[-8]=""" & Equipe1 & """,RC[-1]=""" & Equipe2 & """),AND(RC[-8]=""" & Equipe2 & """,RC[-1]=""" & Equipe1 & """)),1,"""")"
f2.Range("I8:I34").FormulaR1C1 = Formule
f2.Range("I8:I34").Value = f2.Range("I8:I34").Value
Set Lig = f2.Range("I8:I34").Find(1, LookIn:=xlValues, lookat:=xlWhole)
On Error Resume Next
If Err.Number = 0 Then Analyse_et_Permutation
On Error GoTo 0
End If
Next i
End If
'Traitement poule B
If Application.WorksheetFunction.CountA(f1.Range("H19:H" & f1_DerLig_B).Value) <> 0 Then
For i = 19 To f1_DerLig_B
If f1.Cells(i, "H") <> "" Then
Equipe1 = f1.Cells(i, "B")
Equipe2 = f1.Cells(i + 1, "B")
'***********************************************************************************
'Formule de recherche des 2 équipes en doublon
'Poule B
Formule = "=IF(OR(AND(RC[-8]=""" & Equipe1 & """,RC[-1]=""" & Equipe2 & """),AND(RC[-8]=""" & Equipe2 & """,RC[-1]=""" & Equipe1 & """)),1,"""")"
f2.Range("I43:I64").FormulaR1C1 = Formule
f2.Range("I43:I64").Value = f2.Range("I43:I64").Value
Set Lig = f2.Range("I43:I64").Find(1, LookIn:=xlValues, lookat:=xlWhole)
On Error Resume Next
If Err.Number = 0 Then Analyse_et_Permutation
On Error GoTo 0
End If
Next i
End If
Formules
f1.Columns(8).ClearContents
f2.Columns(9).ClearContents
Set Lig = Nothing
Set f1 = Nothing
Set f2 = Nothing
End Sub
Sub Analyse_et_Permutation()
'Récupération des scores
Score_Eq_1 = f2.Cells(Lig.Row, "B")
Score_Eq_2 = f2.Cells(Lig.Row, "C")
MeilleurScore = Application.WorksheetFunction.Max(Score_Eq_1, Score_Eq_2)
If MeilleurScore = Score_Eq_1 Then
Eq = f2.Cells(Lig.Row, "A")
Else
Eq = f2.Cells(Lig.Row, "H")
End If
'donc, c'est la 2ème équipe qui a obtenu le meilleur score
If f1.Cells(i, "B") <> Eq Then 'alors on permute les 2 équipes dans la feuille "Classement", sinon on ne touche à rien
If f1.Cells(i, "B") <> Eq Then 'alors on permute les 2 équipes dans la feuille "Classement", sinon on ne touche à rien
f1.Range(Cells(i, "B"), Cells(i, "AN")).Copy f1.Range(Cells(30, "B"), Cells(30, "AN"))
f1.Range(Cells(i + 1, "B"), Cells(i + 1, "AN")).Copy f1.Range(Cells(i, "B"), Cells(i, "AN"))
f1.Range(Cells(30, "B"), Cells(30, "AN")).Copy f1.Range(Cells(i + 1, "B"), Cells(i + 1, "AN"))
f1.Range(Cells(30, "B"), Cells(30, "AN")).Clear
f2.Cells(Lig.Row, "I").ClearContents
f1.Range(Cells(i, "H"), Cells(i + 1, "H")).ClearContents
End If
End If
End Sub
Sub Formules()
f1.Range("C5:C10").FormulaR1C1 = "=INDEX(R5C1:R10C40,MATCH(RC2,R5C10:R10C10,0),16)"
f1.Range("D5:D10").FormulaR1C1 = "=INDEX(R5C1:R10C40,MATCH(RC2,R5C10:R10C10,0),22)"
f1.Range("E5:E10").FormulaR1C1 = "=INDEX(R5C1:R10C40,MATCH(RC2,R5C10:R10C10,0),28)"
f1.Range("F5:F10").FormulaR1C1 = "=INDEX(R5C1:R10C40,MATCH(RC2,R5C10:R10C10,0),34)"
f1.Range("G5:G10").FormulaR1C1 = "=INDEX(R5C1:R10C40,MATCH(RC2,R5C10:R10C10,0),40)"
f1.Range("C19:C23").FormulaR1C1 = "=INDEX(R19C1:R23C40,MATCH(RC2,R19C10:R23C10,0),16)"
f1.Range("D19:D23").FormulaR1C1 = "=INDEX(R19C1:R23C40,MATCH(RC2,R19C10:R23C10,0),22)"
f1.Range("E19:E23").FormulaR1C1 = "=INDEX(R19C1:R23C40,MATCH(RC2,R19C10:R23C10,0),28)"
f1.Range("F19:F23").FormulaR1C1 = "=INDEX(R19C1:R23C40,MATCH(RC2,R19C10:R23C10,0),34)"
f1.Range("G19:G23").FormulaR1C1 = "=INDEX(R19C1:R23C40,MATCH(RC2,R19C10:R23C10,0),40)"
End Sub |
Partager