Option Explicit
Sub Répartition()
Dim T(), L As Long, Don As Collection, Deg As SsGroup, Sex As SsGroup, _
N As Long, Détail, dC As Long, C As Long, Équ As SsGroup
T = ColUti(Feuil1.[B2:F2], CMin:=5)
Randomize
For L = 1 To UBound(T, 1)
T(L, 5) = Rnd: Next L
Set Don = GroupOrg(T, 3, 4, Null, 5)
L = 0
For Each Deg In Don
For Each Sex In Deg.Contenu
N = 0
For Each Détail In Sex.Contenu
L = L + 1: N = N + 1
For C = 1 To 4: T(L, C) = Détail(C): Next C
T(L, 5) = N: Next Détail, Sex, Deg
Set Don = GroupOrg(T, 5, 3, Null, -4)
ReDim T(1 To 1500, 1 To 10)
L = -1: N = 0
For Each Équ In Don
L = L + 2: N = N + 1
T(L, 1) = "Équipe " & N
For Each Deg In Équ.Contenu
L = L + 1
For Each Détail In Deg.Contenu
dC = IIf(Détail(4) = "G", 1, 6)
For C = 1 To 4: T(L, C + dC) = Détail(C): Next C, Détail, Deg, Équ
Feuil3.[A8].Resize(1500, 10).Value = T
End Sub