View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default Generate random password

Hi,
This will generate a random password of form AAAAnnnn. Enter =genpw()
into any cell.

Function GenPw()
Dim password As String
password = ""
For i = 1 To 4
password = password + Chr((Int(Rnd() * 26) + 65))
Next
password = password + Trim(Str(Int(Rnd() * 10000)))
GenPw = password
End Function


HTH

" wrote:

Hi,

I would like to set up a macro/worksheet function that creates random
alphanumeric passwords for users of a database.
To hep me achieve this I have set up the following.
Starting at ColA2 I have a list of forenames and in ColB2 I have a list
of surnames. There are currently 120 users in my list. Would it be
possible to run a macro which picks up the first 2 initials of the
forename and surname and then for it to produce a random 4 digit pin
number and place the completed result as a password starting in ColC2.
For example, Mickey Mouse would become mimo1977.

The only drawback with the method is the simple logic that I am using.
Would it be possible to 'mix up' the initials so Mickey Mouse would
look like omni1977.

Maybe there is an easier way to do this without macros using worksheet
functions - I would welcome alternative solutions.

Grateful for a response

Many thanks

Tony