Sub test2()
For Each ag In Selection
S = ""
s1 = Chr(Int(26 * Rnd() + 65))
s2 = Chr(Int(26 * Rnd() + 65))
For I = 1 To 3
S = S & Int(10 * Rnd())
Next
S = s1 & s2 & S
If ag.Value = "" Then
ag.Value = S
End If
Next
End Sub
Sub GetRand()
Dim S$, D, I%
Set D = CreateObject("scripting.dictionary")
Selection.NumberFormatLocal = "@"
W = Selection.Count
Do
S = ""
For I = 1 To 4
S = S & Int(10 * Rnd())
Next
D(S) = ""
Loop Until D.Count = W
K = D.KEYS
For I = 1 To Selection.Count
Selection(I) = Format(K(I - 1), "0000")
Next
End Sub