Sub random2()
debut = Timer
Application.ScreenUpdating = False
Sheets("Res").Cells.Clear
Range("A1:IV1").Copy
Sheets("Res").Cells(1, 1).PasteSpecial Paste:=xlPasteValues
Sheets("Res").Cells(1, 1).PasteSpecial Paste:=xlPasteFormats
tablo = Range("A2:A" & Range("A65536").End(xlUp).Row)
Dim t2()
ReDim t2(1 To 2, 0)
Set d = CreateObject("Scripting.Dictionary")
For n = LBound(tablo, 1) To UBound(tablo, 1)
If Not d.exists(tablo(n, 1)) Then
d(tablo(n, 1)) = 1
t2(1, UBound(t2, 2)) = tablo(n, 1)
t2(2, UBound(t2, 2)) = n + 1
ReDim Preserve t2(1 To 2, UBound(t2, 2) + 1)
Else
For m = LBound(t2, 2) To UBound(t2, 2) - 1
If t2(1, m) = tablo(n, 1) Then
t2(2, m) = t2(2, m) & "-" & n + 1
End If
Next m
End If
Next n
Set f = CreateObject("Scripting.Dictionary")
While f.Count < UBound(t2, 2) + 1
Randomize
w = Int((UBound(t2, 2) + 1) * Rnd)
f(w) = 1
Wend
ww = f.keys
For s = LBound(ww) To UBound(ww)
suite = suite & melange(t2(2, ww(s)))
Next s
suite = Left(suite, Len(suite) - 1)
ligne = 2
zz = Split(suite, "-")
For n = LBound(zz) To UBound(zz)
Range("A" & zz(n) & ":IV" & zz(n)).Copy
Sheets("Res").Cells(ligne, 1).PasteSpecial Paste:=xlPasteValues
Sheets("Res").Cells(ligne, 1).PasteSpecial Paste:=xlPasteFormats
ligne = ligne + 1
Next n
Application.CutCopyMode = False
Application.ScreenUpdating = True
Sheets("Res").Select
ActiveWindow.Zoom = 25
MsgBox (Timer - debut)
End Sub
Function melange(liste)
x = Split(liste, "-")
Set e = CreateObject("Scripting.Dictionary")
While e.Count < UBound(x) + 1
Randomize
Z = Int((UBound(x) + 1) * Rnd)
e(Z) = 1
Wend
t3 = e.keys
For n = LBound(t3) To UBound(t3)
melange = x(t3(n)) & "-" & melange
Next n
End Function