Here's a routine posted in these NGs some time ago by a guy called. David
Higgs. Pass it the password length, and it returns the result
Function GeneratePassword(iLen As Integer) As String
Dim i As Integer
For i = 1 To iLen
If Rnd > 0.5 Then
GeneratePassword = GeneratePassword & _
Chr(Int((Asc("9") - Asc("0") + 1) * Rnd + Asc("0")))
Else
GeneratePassword = GeneratePassword & _
Chr(Int((Asc("Z") - Asc("A") + 1) * Rnd + Asc("A")))
End If
Next i
End Function
or, if you want a formula, but be aware it will change every time you
recalculate:-
=CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))&CHAR
(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))