Sub TirageNoms()
Dim TabNom As Variant, temp As Variant, lig As Integer, i As Byte, j As Integer, k As Integer, l As Integer
Dim n As Integer, x As Double, Z As Byte, Nbinscrits As Byte
Randomize
With Sheets("TIRAGELISTING")
Set c = .Range("A:A").Find("~***", LookIn:=xlValues)
If c Is Nothing Then Exit Sub
TabNom = .Range("A3:A" & c.Row)
.Range("B3:B" & c.Row).ClearContents
' Fin de liste
' Nombre de joueurs inscrits
Nbinscrits = c.Row - 1
End With
' Mise en tableau des noms et des nombres aléatoires
ReDim Tablo(1 To UBound(TabNom), 1 To 3)
For j = 1 To UBound(TabNom)
Tablo(j, 1) = Cells(j + 1, 1)
Z = 0
Do
x = Rnd
For k = 1 To j
If Tablo(k, 2) = x Then
Z = 0
Else
Z = 1
End If
Next k
Loop Until Z = 1
Tablo(j, 2) = x
Tablo(j, 3) = x
Next j
' Placer les nombres dans l'ordre décroissant dans la colonne 3 du tableau
For k = 1 To UBound(Tablo)
For l = 1 To UBound(Tablo)
If Tablo(k, 3) < Tablo(l, 3) Then
temp = Tablo(k, 3)
Tablo(k, 3) = Tablo(l, 3)
Tablo(l, 3) = temp
End If
Next l
Next k
' Mise en place des noms en colonne B
For i = 1 To UBound(Tablo)
For j = 1 To UBound(Tablo)
If Tablo(i, 3) = Tablo(j, 2) Then
Cells(i + 1, 2) = Tablo(j, 1)
End If
Next j
Next i
End Sub