Generating 500,000 random unique numbers

chris meardon

New Member
Joined
May 28, 2010
Messages
5
Hi Guys,

I need to produce half a million random unique numbers onto a spreadsheet.

Can you guys help? obviously the rand function is ok but the numbers arent unique.

the numbers need to be within 1-9999

the other issue i have is displaying the numbers, all numbers need 4 digits, for example if the number is 35 it would need to be displayed 0035 to have 4 digits.

Thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
no its not possible without decimals, according to probablity.. there are only 10000 possible combinations from 0000 to 9999..

Of the 10000 4-digit numbers 5040 are non-repeating, 4320 one-repeating (doubles), 270 two-repeating (dual-doubles), 360 one-tripled, and 10 quadruples
 
Upvote 0
Ok so I would need to add another digit on, so 5 digit number? perhaps thats why i was getting some copys using the RAND fuction simply because there wasnt enough numbers to have them all unique??
 
Upvote 0
however many numbers are required, this could easily be done by, e.g. column A containing the formula =Rand()
Column B containing the unique numbers 1 to 9999 (or whatever) and each time you wish to generate a sequence, press [F9] then sort the two columns using column A as the key.

custom format column B as '0000'
 
Upvote 0
You need 6 digits...

But that isn't the reason why you have duplicates - the RAND function does not allow for unique numbers.
 
Upvote 0
Use the RANK function applied on the random numbers, that should lead to unique numbers.
 
Upvote 0
Sorry Im struggling to see how the rank would be used to make sure they are unique? I dont have much experience with the rank funtion
 
Upvote 0

Forum statistics

Threads
1,215,124
Messages
6,123,187
Members
449,090
Latest member
bes000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top