Option Explicit 'oblige à déclarer toutes les variables
Sub Macro1()
Dim x As Byte 'déclare la variable x
Dim ad As String 'déclare la variable ad
Dim c As Range 'déclare la variable c
Dim col As Integer 'déclare la variable col
col = ActiveCell.Column 'définit la variable col
Randomize 'lance la fonction aléatoire
For x = 1 To 199 'boucle sur 199 cellule
If Cells(1, col) = '' Then 'condition1 : si la cellule A1 est vide, alors
Cells(1, col) = Int(199 * Rnd) 'A1 = aléatoire ente 0 et 199
Else 'sinon
Cells(x, col) = Int(199 * Rnd) 'la cellule A_x = aléatoire entre 0 et 99
With Range(Cells(1, col), Cells(x, col)) 'avec la plage A1:A_x
Set c = .Find(Cells(x, col).Value, , , xlWhole) 'définit la variable c = chercher la première valeur de A_x
If Not c Is Nothing Then 'condition2 : si recherche non infructueuse
ad = c.Address 'définit la variable ad (adresse de la première valeur trouvée = A_x)
Set c = .FindNext(c) 'redéfinit la variable c = prochaine valeur A_x recherché
If Not c Is Nothing And c.Address <> ad Then 'condition3 : si recherche non infructeueuse et adresse différente de la premiere valeur trouvée
x = x - 1 'redéfinit la variable x
End If 'fin condition3
End If 'fin condition2
End With 'fin avec plage A1:A_x
End If 'fin condition1
Next x 'prochaine cellule de la boucle
Cells(Int(200 * Rnd) + 1, col).Select 'sélectione aleatoirement une cellule dans la plage (1:200)
Selection.Insert Shift:=xlDown 'insère en décalant vers le bas
Selection.Value = 199 'place la dernière valeur = 199
Cells(1, col).Select 'sélectionne la première cellule
End Sub