Dim ChooseType As Integer
Dim UpperLower As Integer
Dim pwStore As String
Dim pwLength As Integer
Dim pw As String
'Length of password'
pwLength = 8
For i = 1 To pwLength
ChooseType = Round(Rnd)
If ChooseType = 1 Then
'Number'
pwStore = Chr(Int((57 - 48 + 1) * Rnd + 48))
Else
'Alphabet'
UpperLower = Round(Rnd)
If UpperLower = 1 Then
'Upper Case'
pwStore = UCase$(Chr(Int((90 - 65 + 1) * Rnd + 65)))
Else
'Lower Case'
pwStore = LCase$(Chr(Int((90 - 65 + 1) * Rnd + 65)))
End If
End If
pw = pw & pwStore
Next i
MsgBox "Password generated = " & pw