ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Random Ltters and Numbers (https://www.excelbanter.com/excel-programming/330284-random-ltters-numbers.html)

Frank

Random Ltters and Numbers
 
Hi Can someone help me please I need to grenerate a random 11 characters and
Numbers mixed I can do it with numbers but I haven't done it with letters,
has anybody done this kind of thing before any help would be much appreciated.
Thanks
Frank

Chris Ferguson

Random Ltters and Numbers
 
How about having all the letters and numbers in one column, a random number
in the next column. Sort on the random number column and then the top 11
rows will be your random 11 characters.

Chris


"Frank" wrote in message
...
Hi Can someone help me please I need to grenerate a random 11 characters
and
Numbers mixed I can do it with numbers but I haven't done it with letters,
has anybody done this kind of thing before any help would be much
appreciated.
Thanks
Frank




bigwheel

Random Ltters and Numbers
 
"Frank" wrote:

Hi Can someone help me please I need to grenerate a random 11 characters and
Numbers mixed I can do it with numbers but I haven't done it with letters,
has anybody done this kind of thing before any help would be much appreciated.
Thanks
Frank


One way:-

Sub RandomGenerate()
For a = 1 To 11
x = Int(Rnd * 2) 'decide whether number or character
If x = 1 Then
Cells(a, 1) = Chr(Int(26 * Rnd) + 65) 'character codes start
at 65
Else
Cells(a, 1) = Int(9 * Rnd)
End If
Next a
End Sub


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com