Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Alphanumeric random number?

Is it possible to create alphanumeric random numbers ?

  #2   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Alphanumeric random number?

One play ..

Put in any cell, copy it down / across as desired:
=CHAR(randbetween(65,90))&randbetween(1000,9999)

Above will return random strings comprising of a capital alpha between A -
Z, concatenated with a random 4 digit number between 1,000 and 9999, eg:

N9484
L7773
F3785
Y1198
C5555
etc

Pressing F9 re-generates. Adapt to suit ..
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Michelle B" wrote:
Is it possible to create alphanumeric random numbers ?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Alphanumeric random number?

Thanks Max
Would never have got there by myself !!

"Max" wrote:

One play ..

Put in any cell, copy it down / across as desired:
=CHAR(randbetween(65,90))&randbetween(1000,9999)

Above will return random strings comprising of a capital alpha between A -
Z, concatenated with a random 4 digit number between 1,000 and 9999, eg:

N9484
L7773
F3785
Y1198
C5555
etc

Pressing F9 re-generates. Adapt to suit ..
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Michelle B" wrote:
Is it possible to create alphanumeric random numbers ?

  #4   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Alphanumeric random number?

You're welcome, Michelle !
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Michelle B" wrote in message
...
Thanks Max
Would never have got there by myself !!



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 698
Default Alphanumeric random number?

Hi Michelle B,

Using this formula (which should all be on one line) go to Insert Name
Define Names in workbook XX Refers to Enter the long formula OK

=MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
abcdefghijklmnopqrstuvwxyz",
1+INT(62*RAND()),1)


On your worksheet use this formula to generate your alpha-numeric numbers.

=XX&XX returns a 2 character a/n number
=XX&XX&XX returns 3 character a/n number
etc.

Adjust to the length of the alpha-numeric number you want by addin "&XX's"
to the worksheet formula.

HTH
Regards,
Howard


"Michelle B" wrote in message
...
Is it possible to create alphanumeric random numbers ?





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Alphanumeric random number?

Thanks - have tried this & it works perfectly, but is there any way to
guarantee a combination of 2 alpha & 2 numeric in random positions every time?


"L. Howard Kittle" wrote:

Hi Michelle B,

Using this formula (which should all be on one line) go to Insert Name
Define Names in workbook XX Refers to Enter the long formula OK

=MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
abcdefghijklmnopqrstuvwxyz",
1+INT(62*RAND()),1)


On your worksheet use this formula to generate your alpha-numeric numbers.

=XX&XX returns a 2 character a/n number
=XX&XX&XX returns 3 character a/n number
etc.

Adjust to the length of the alpha-numeric number you want by addin "&XX's"
to the worksheet formula.

HTH
Regards,
Howard


"Michelle B" wrote in message
...
Is it possible to create alphanumeric random numbers ?




  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 136
Default Alphanumeric random number?

Hello Michele,

Try this UDF:
Function ranpw(l As Long, ByVal ca As Long, ByVal cn As Long) As String
'random alpha-numeric password with length l and a minimum of
'ca alpha characters and cn numerical characters
Dim s As String, sr As String
Dim r As Long, i As Long

Application.Volatile
s = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm nopqrstuvwxyz"
If l < 1 Or ca < 0 Or cn < 0 Or l < ca + cn Then
ranpw = CVErr(xlErrNum)
Exit Function
End If

For i = 1 To l
If l - i + 1 = ca Then
r = 52 * Rnd() + 11
ElseIf l - i + 1 = cn Then
r = 10 * Rnd() + 1
Else
r = 62 * Rnd() + 1
End If
If r 10 Then
If ca 0 Then ca = ca - 1
Else
If cn 0 Then cn = cn - 1
End If
sr = sr & Mid(s, r, 1)
Next i

ranpw = sr

End Function

Press ALT + F11, insert a module, and copy this function into the
module.

If you need a password of length 5 with at least 2 alpha and 2
numerical characters:
=ranpw(5,2,2)

HTH,
Bernd

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random cell/number and dont repeat selected cell/number Hector PR Excel Discussion (Misc queries) 0 October 16th 06 05:02 PM
Pulling Data off Web - Need Function Help patfergie44 Excel Worksheet Functions 9 June 22nd 06 03:27 AM
How do I generate only one random number without it refreshing? joshman Excel Worksheet Functions 5 June 21st 06 06:53 AM
same number appears in a random number generator Carmel Excel Worksheet Functions 4 May 28th 06 12:22 AM
Random Number Questions Greegan Excel Worksheet Functions 1 January 5th 05 02:00 AM


All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"