'Si tu veux les 6 premiers tu mets 6
Public Const monMax As Long = 5
Public Cell As Range
Public tab1(1 To monMax, 1 To 18) As Variant
Public tab2(1 To monMax, 1 To 18) As Variant
Public tab3(1 To monMax, 1 To 18) As Variant
Public tab4(1 To monMax, 1 To 18) As Variant
Public tab5(1 To monMax, 1 To 18) As Variant
Public tab6(1 To monMax, 1 To 18) As Variant
Public tab7(1 To monMax, 1 To 18) As Variant
Public Tablo As Variant
Sub LesPremiers()
'Macro moins rapide que la précédente à cause des trois boucles imbriquées
'Mais intéressante pour l'utilisation de tableaux
Dim a, b, c, d, e, f, g As Integer
'on "fige" l'écran
Application.ScreenUpdating = False
'on initialise le compteur
a = 0: b = 0: c = 0: d = 0: e = 0: f = 0: g = 0: l = 2
'on recherche la dernière ligne de la colonne E
DerLi = Sheets("TOURNOI").Columns(5).Find("*", , , , , xlPrevious).Row
'le tableau de tableaux, M E R C I à Épaf
Tablo = Array("", tab1, tab2, tab3, tab4, tab5, tab6, tab7)
For Each Cell In Sheets("TOURNOI").Range("E3:E" & DerLi)
'on évalue le premier caractère
Select Case Left(Cell.Value, 1)
Case 1: If a < monMax Then RemplirTableaux a, 1 'voir la macro plus bas
Case 2: If b < monMax Then RemplirTableaux b, 2
Case 3: If c < monMax Then RemplirTableaux c, 3
Case 4: If d < monMax Then RemplirTableaux d, 4
Case 5: If e < monMax Then RemplirTableaux e, 5
Case 6: If f < monMax Then RemplirTableaux f, 6
Case 7: If g < monMax Then RemplirTableaux g, 7
End Select
'on applique une condition pour sortir de la boucle
If a + b + c + d + e + f + g = 7 * monMax Then Exit For
Next Cell
'on efface
Sheets("Serie").Range("A3:R" & 8 + 7 * monMax).ClearContents
'la récupération des données avec 3 boucles imbriquées
For i = 1 To UBound(Tablo)
For j = 1 To monMax ' ou UBound(tab1, 1)
For k = 1 To UBound(tab1, 2)
Sheets("Serie").Cells(j + l, k).Value = Tablo(i)(j, k)
Next k
Next j
l = l + monMax + 1 ' + 1 pour sauter une ligne
Next i
' on actualise l'écran
Application.ScreenUpdating = True
End Sub
Sub RemplirTableaux(Lettre, Pos)
Lettre = Lettre + 1
For i = 1 To 18
Tablo(Pos)(Lettre, i) = Sheets("TOURNOI").Cells(Cell.Row, i).Value
Next
End Sub