Sub Tirages()
Dim a$, L%, tablo, ub%, b(), i%, r%, j%
a = "AAAAAAAAAABBCCCDDDEEEEEEEEEEEEEEEEEEFFGGHHIIIIIIIIIJKLLLLLLLMMMNNNNNNNNOOOOOOOPPPQRRRRRRRRSSSSSSSSTTTTTTTTUUUUUUUUVVWXYZ"
L = Len(a) '120
Randomize
With [B2:K13] 'tableau 12 x 10, à adapter
tablo = .Value 'matrice, plus rapide
ub = UBound(tablo, 2)
ReDim b(ub - 1) 'matrice tempon
For i = 1 To UBound(tablo)
For j = 1 To ub
r = Application.RandBetween(1, L)
b(j - 1) = Mid(a, r, 1)
a = Left(a, r - 1) & Mid(a, r + 1)
L = L - 1
Next j
tri b, 0, ub - 1
For j = 1 To ub
tablo(i, j) = b(j - 1)
Next j, i
.Value = tablo 'restitution
End With
End Sub
Sub tri(a, gauc, droi) ' Quick sort
Dim ref, g, d, temp
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call tri(a, g, droi)
If gauc < d Then Call tri(a, gauc, d)
End Sub