Sub Combinaisons_3a3()
Dim dur#, t, ub&, rc&, col%, a$(), i&, j&, k&, n&
dur = Timer
Application.ScreenUpdating = False
t = [A2:A151] 'à adapter
ub = UBound(t)
rc = Rows.Count - 1
ReDim a(1 To rc, 1 To 1)
col = 2
With Columns(col).Resize(, Columns.Count - col + 1)
.NumberFormat = "@" 'format Texte
.Delete 'RAZ
End With
For i = 1 To ub - 2
For j = i + 1 To ub - 1
For k = j + 1 To ub
n = n + 1
a(n, 1) = t(i, 1) & "-" & t(j, 1) & "-" & t(k, 1)
If n = rc Then
Cells(1, col) = "Col " & col - 1
Cells(2, col).Resize(rc) = a 'restitution de la colonne entière
If col Mod 2 = 0 Then Columns(col).Interior.ColorIndex = 24
ReDim a(1 To rc, 1 To 1) 'RAZ
n = 0: col = col + 1
End If
Next k, j, i
If n Then
Cells(1, col) = "Col " & col - 1
Cells(2, col).Resize(n) = a 'restitution de la colonne partielle
If col Mod 2 = 0 Then Cells(1, col).Resize(n + 1).Interior.ColorIndex = 24
End If
Columns(2).Resize(, col - 1).AutoFit 'ajustement largeur
ActiveSheet.DrawingObjects(1).Left = Columns(col + 1).Left + 1 'position du bouton
Application.ScreenUpdating = True
MsgBox Format(Application.Combin(ub, 3), "#,##0") & " combinaisons listées en " & Format(Timer - dur, "0.00 \s")
End Sub