J'ai retrouvé le fichier excel avec la macro permettant de réaliser cette action :
Sub Equipes()
Dim Lg%, i%, Plg As Range, Cel As Range, N
Lg = Range("b1") + 2
'---- contrôle niveau individuel et nombre joueurs ----
For Each Cel In Range("f3:f" & Lg)
If Cel = "" Then
Cel.Activate
MsgBox ("Champ " & Cel.Offset(0, -1) & " Obligatoire")
Exit Sub
End If
Next Cel
If Range("b1") Mod Range("b2") <> 0 Then
MsgBox ("Nombre de joueurs incompatible !")
Exit Sub
End If
If Lg > Range("e65000").End(xlUp).Row Then
MsgBox ("Manque joueur !")
Range("e65536").End(xlUp)(2).Activate
Exit Sub
End If
'----
Application.ScreenUpdating = False
Range("h5:n100").ClearContents
Range("i3:k4").AutoFill Destination:=Range("i3:k" & Range("b1") + 2)
Set Plg = Range("L3:L100")
N = 1
For i = 3 To Lg Step Range("b2")
Cells(i, 8) = "équipe " & N
Cells(i, 12) = "=SUM(k" & i & ":k" & i + Range("b2") - 1 & ")"
N = N + 1
Next i
Call Tirage
Do While Application.Max(Plg) - Application.Min(Plg) > Range("L1") Or Application.Sum(Plg) = 0
Call Tirage
Loop
'---- sépare les équipes par un trait rouge ----
Range(Cells(3, 8), Cells(100, 12)).Borders.LineStyle = xlNone
For i = 3 To Range("b1") + 2 Step Range("b2")
With Range(Cells(i, 8), Cells(i, 12))
.Borders(xlEdgeTop).LineStyle = xlDouble
.Borders(xlEdgeTop).ColorIndex = 3
End With
Next i
End Sub
Sub Tirage()
Dim Temp As Integer, Existe As Boolean
Dim i%, J%, Nbr$, N
Dim Tableau(200) As Integer, RDest As Range
Nbr = Range("b1")
Set RDest = Cells(3, 14)
Randomize
For i = 1 To Nbr
Existe = True
While Existe
Temp = Int(Nbr * Rnd + 1)
For J = 1 To Nbr
If Temp = Tableau(J) Then
Existe = True
Exit For
Else
Existe = False
End If
Next J
Wend
Tableau(i) = Temp
Next i
For i = 1 To Nbr
RDest(i).Value = Tableau(i)
Next i
End Sub
Quelqu'un aurait la gentillesse de convertir ce langage VBA en Javascript pour google sheet ?