Public aOut
Sub BSALV()
t0 = Timer
Combinaisons Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"), 4 'tous les combinaisons de 4 avec ces 10 lettres
t1 = Timer
Range("A1").Resize(UBound(aOut), UBound(aOut, 2)).Value = aOut 'vers la feuille
MsgBox Format(t1 - t0, "0.00\s") & vbLf & Format(Timer - t1, "0.00\s")
End Sub
Sub Combinaisons(arr, N As Integer)
Dim aAux, i, j, Ptr, lComb, iBase
iBase = UBound(arr) + 1 'nombre de lettres
lComb = WorksheetFunction.Combin(iBase, N) 'nombre de combinaisons
ReDim aOut(1 To lComb, 1 To N) 'preparer matrices
ReDim aAux(1 To N)
Do While Ptr < lComb
Ptr = Ptr + 1 'pointer
If Ptr = 1 Then
For i = 1 To N: aAux(i) = i: Next 'initialisation
Else
aAux(N) = aAux(N) + 1
If aAux(N) > iBase Then
For i = N To 2 Step -1
If aAux(i) > iBase + i - N Then
aAux(i - 1) = aAux(i - 1) + 1
If aAux(i - 1) <= iBase + i - 1 - N Then
For j = i To N
aAux(j) = aAux(j - 1) + 1
Next
Exit For
End If
End If
Next
End If
End If
For i = 1 To N
aOut(Ptr, i) = arr(aAux(i) - 1) 'vos lettres au lieu de ces indexes
Next
Loop
End Sub