Pinched from someone else, (needs additional character sets, e.g. mixed case, text & numbers)
Dim Rand As String Dim i As Integer, RndNo As Integer, XSet As Integer Dim MyCase As Integer Application.Volatile Select Case MySet Case Is = "1" 'Upper case MyCase = 65: XSet = 26 Case Is = "2" 'Lower Case MyCase = 97: XSet = 26 Case Is = "3" 'Leading Capital MyCase = 97: XSet = 26 Case Is = "4" 'Text digits MyCase = 48: XSet = 10 Case Is = "5" 'Numeric digits MyCase = 48: XSet = 10 End Select If MySet = 3 Then 'Set leading character of "Name" i = i + 1 Randomize Rand = Rand & Chr(Int((26) * Rnd + 65)) End If 'Set random length of string RndNo = Int((MaxLen + 1 - MinLen) * Rnd + MinLen) Do i = i + 1 Randomize Rand = Rand & Chr(Int((XSet) * Rnd + MyCase)) Loop Until i = RndNo RandomString = Rand 'Convert string to number If MySet = 5 Then RandomString = RandomString * 1 End Function