Re-,
Effectivement, pour le premier "Bug", je n'avais pas pris en compte l'initialisation (aucun code....)
Remplace par ceci :
Sub code_alea_2()
Dim Cel As Range
Dim AFaire As Long, Nb As Long, Total As Long
Dim Uniques As Object
Set Uniques = CreateObject("Scripting.Dictionary")
AFaire = Application.CountA(Columns(1)) - Application.CountA(Columns(2))
If AFaire > 0 Then
If Cells(Rows.Count, 2).End(xlUp).Row > 1 Then
For Each Cel In Range("B2:B" & Cells(Rows.Count, 2).End(xlUp).Row)
Uniques(Cel.Value) = Cel.Value
Next Cel
End If
Total = Uniques.Count + AFaire
Do While Uniques.Count < Total
Randomize (Timer)
Nb = Int(Rnd() * 89999) + 10000
Uniques(Nb) = Nb
Loop
End If
Range("B2").Resize(Total) = Application.Transpose(Uniques.Items)
End Sub
Pour le deuxième souci, il n'y a pas de génération de code, s'il n'y a pas de nom...
Bon dimanche