Random letteers

J

Jim

Excel has a function named RANDBETWEEN which generates
random numbers between your predefined upper and lower
limits.

How can I create a column of 6 random letters (not numbers)
 
K

Ken Wright

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))
 
N

Norman Harker

Hi Jim!

Here's a way without getting repeats.

Type in the letters A - Z in A1:A26
In B1:
=RAND()
Copy down to B26
In C1:
=INDEX($A$1:$A$26,RANK(B1,$B$1:$B$26),1)
Copy down to C6

These letters will change each time you calculate so you might want to
copy and paste special values once you have generated 6 letters.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top