Try this
The only problem with this code is that it might sometimes not create Alphanumeric Strings...
You can put in an extra check to see if the string is an alphanumeric and then only store it in a cell... I am sure you will be able to do it... If you get stuck simply post and we will definitely help you...
Code:Sub GenerateRandomString() '~~> This will generate a passwords 5 chars long and '~~> Store it to Cell A1 in Sheet1 Sheets("Sheet1").Range("A1").Value = RandomString(5) End Sub Function RandomString(Lngth As Integer) As String Randomize Dim baseString As String baseString = "abcdefghijklmnopqrstuvwxyz" baseString = baseString & UCase(baseString) & "0123456789" Dim i As Long For i = 1 To Lngth RandomString = RandomString & Mid$(baseString, Int(Rnd() * Len(baseString) + 1), 1) Next End Function




Reply With Quote