Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2000 random numbers & letters 1

Status
Not open for further replies.

MJamison07

Technical User
Dec 13, 2001
54
US
I am trying to create passwords for a list of employees & I want Excel to do it for me. I would like random 4-digit passwords for each employee that use numbers & letters. Is it possible?

Thanks.

M Jamison
 
A solution to a similar question posted by Harlan Grove in the MS groups:_

"Glenn" wrote...
>I need to create random six digit passwords made up of letters and numbers.
>Is it possible to do this in excel?

FTHOI, here's an approach that doesn't require VBA. Define the following names
(Insert > Names > Define).

alphanum referring to
="a0b1c2d3ef4g5h6ij7k8l9mn0o1p2q3rs4t5u6vw7x8y9z"

password referring to
=MID(alphanum,INT(1+46*RAND()),1)&MID(alphanum,INT(1+46*RAND()),1)
&MID(alphanum,INT(1+46*RAND()),1)&MID(alphanum,INT(1+46*RAND()),1)
&MID(alphanum,INT(1+46*RAND()),1)&MID(alphanum,INT(1+46*RAND()),1)

Then the worksheet cell formula =password will give you different 6-char
passwords made up of decimal digits and letters.

You would just need 4 of them and not 6.

--------------------------------------

If you prefer a function route, then here's a routine posted in the MS NGs some time ago by a guy called. David
Higgs. Pass it the password length, and it returns the result

Function GetPW(iLen As Integer) As String

Dim i As Integer

For i = 1 To iLen
If Rnd > 0.5 Then
GetPW = GetPW & _
Chr(Int((Asc("9") - Asc("0") + 1) * Rnd + Asc("0")))
Else
GetPW = GetPW & _
Chr(Int((Asc("Z") - Asc("A") + 1) * Rnd + Asc("A")))
End If
Next i

End Function

You would put this into a module and then in any cell just type for example =getpw(4)

Regards
Ken................

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
The Insert>Name>Define approach worked beautifully. I searched before I posted but didn't find that response. Thanks for passing it my way.
MJamison
 
My pleasure

Regards
Ken............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top