Option Explicit
Sub test3()
Dim c As Range, maplage As Range, i As New Collection, ii, x As String, y As String
Dim ws As Worksheet, r As Range
Randomize
On Error Resume Next
Set maplage = Application.InputBox("selectionnez une ou" & vbLf _
& "plusieurs plage(s) de cellules !!!", , , , , , , 8)
On Error GoTo 0
If Not maplage Is Nothing Then
For Each c In maplage
debut:
Do While i.Count < 10
x = Choose(Int((36 * Rnd) + 1), "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" _
, "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" _
, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
On Error Resume Next
i.Add x, CStr(x)
Loop
On Error GoTo 0
For Each ii In i
y = y & ii
Next ii
Set i = Nothing
For Each ws In Worksheets
Set r = ws.Cells.Find(y, , xlValues, xlPart, , , False)
If Not r Is Nothing Then y = "": GoTo debut
Next ws
Set r = Nothing
c.Value = y
y = ""
Next c
End If
End Sub