1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Sub test()
Dim nbpuissance, chaine As String, fin As Long, finL As Long, L As String, dico As Object
strLettres = Split("a,b,c,d,e,f,g", ",")
Set dico = CreateObject("Scripting.Dictionary")
Set dicol = CreateObject("Scripting.Dictionary")
nbpuissance = UBound(strLettres) * UBound(strLettres)
fin = 0
Randomize
Do
chaine = ""
finL = 0
Do
DoEvents
L = strLettres(Rnd * 6)
If Not dicol.exists(L) Then
dicol(L) = "": finL = finL + 1: chaine = chaine & L
End If
Loop Until finL = 7
If Not dico.exists(chaine) Then
dico(chaine) = chaine: fin = 0
Else
fin = fin + 1
End If
dicol.RemoveAll
Loop Until fin = nbpuissance
Cells(1, 1).Resize(dico.Count, 1) = Application.Transpose(dico.items())
End Sub |
Partager