Hi everyone!
I have this project for a client who wants me to produce 200,000 pcs of scratch cards (for mobile phones) and the last time I tried generating 6,000 "random unique-non repeated numbers" using randbetween there were about 150 duplicates that came up. I would like to know how if there is really a way in excel to do this..
any help will be appreciated..
by the way, below is a sample:
SERIAL PIN
20319422 ACA95368
thank you!!
please post in the correct sub forum
"Unless otherwise stated all my comments are directed at OP"
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
Try this, put this formula in A1:
=LEFT(INT(RAND()*10000000000), 8) + 0
Put this B1:
=CHAR(RANDBETWEEN(1,26)+64) & CHAR(RANDBETWEEN(1,26)+64) & CHAR(RANDBETWEEN(1,26)+64) & TEXT(RANDBETWEEN(1,99999), "00000")
Copy both cells down 6000 rows. Pretty unlikely you'll get any dupes.
I've asked the moderators to move this thread to the appropriate forum.
Last edited by JBeaucaire; 01-07-2012 at 12:03 PM. Reason: Changed ALPHA portion to something shorter, NUMERIC to something shorter
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
It's a bit slow generating 200,000 numbers...
Sub UniqueRandomNumbers() 'Creates a list of numbers starting in A1 Dim HowMany As Long Dim a As String Dim ncRandList As New Collection Dim r As Range Dim x As Long HowMany = 6000 Randomize On Error Resume Next Do While ncRandList.Count < HowMany a = Int(Rnd() * 99999999) + 1 ncRandList.Add a, CStr(a) Loop On Error GoTo 0 Application.ScreenUpdating = False For Each r In Range("a1").Resize(ncRandList.Count, 1) x = x + 1 r = ncRandList(x) Next r Application.ScreenUpdating = True End Sub
Why not just make a list of 200000 sequential numbers and then put them in random order?
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
You can easily check for duplicates by sorting the output A-Z, adding a helper column with a formula =A2-A1 and copy down, then copy the helper column and paste as values, and finally sort the helper column A-Z. if there are any duplicates, you will see a zero value at the top of the list.
As for alpha-numeric, not sure... would the alpha characters always be in the same position in the string?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks