How to create a list of random unique numbers in excel
Question: How do I create a random list of unique numbers from say 1 to 10, without using VBA:
and without enabling iterative calculation in excel options and not using "helper" columns?
Answer:
Array formula in A2:
How to enter an array formula
- Select cell A2
- Copy / Paste above array formula to formula bar

- Press and hold CTRL + SHIFT
- Press Enter
- Release all keys
Copy cell A2 and paste down as far as needed.
Explaining array formula in cell A2
Step 1 - Create an array
ROW($1:$10) creates this array {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Step 2 - Create a criterion to avoid duplicate numbers
COUNTIF($A$1:A1, ROW($1:$10)) makes sure no duplicate numbers are created. The formula has both absolute and relative cell references ($A$1:A1). When the formula are copied down to cell A3 the cell reference changes to $A$1:A2. The value in cell A2 can´t be randomly selected again.
In cell A2, COUNTIF($A$1:A1, ROW($1:$10)) creates this array: {0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Step 3 - Create a new dynamic array
ROW($1:$10)*NOT(COUNTIF($A$1:A1, ROW($1:$10))) creates this array in cell A2: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
If the array formula randomly selects the number 2 in cell A2, the formula in cell A3 creates this array: {1, 0, 3, 4, 5, 6, 7, 8, 9, 10}
Number 2 can´t be selected anymore.
Step 4 - Calculate the number range in Randbetween(bottom, top)
The bottom value is always 1. The top value changes depending on current cell.
In cell A2 the top value is 10.
In cell A3 the top value is 9
and so on..
Formula in cell A2: 11-ROW(A1) equals 10. (11-1=10)
Formula in cell A3: 11-ROW(A2) equals 9. (11-2=9)
and so on..
Step 5 - Create a random number
=LARGE(ROW($1:$10)*NOT(COUNTIF($A$1:A1, ROW($1:$10))), RANDBETWEEN(1,11-ROW(A1)))
RANDBETWEEN(1,11-ROW(A1))
becomes
RANDBETWEEN(1,11-1)
becomes
RANDBETWEEN(1,10)
and returns a random number between 1 and 10.
Step 6 - Select a random number in array
=LARGE(ROW($1:$10)*NOT(COUNTIF($A$1:A1, ROW($1:$10))), RANDBETWEEN(1,11-ROW(A1)))
becomes
=LARGE({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, RANDBETWEEN(1,10))
becomes
=LARGE({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, random_number) and returns a random number between 1 and 10.
How to customize array formula to your excel work sheet
If your list starts at F3 change $A$1:A1 to $F$2:F2 in the above array formula. To change the numbers from 1 to 10 to, for example, 2 to 12, change $1:$10 to $2:$12 also in the above array formula.
Press F9 to generate a new random list of unique numbers.
Download excel sample file for this tutorial.
unique-random-list-of-numbers.xls
(Excel 97-2003 Workbook *.xlsx)
Functions in this article:
INDEX(array,row_num,[column_num])
Returns a value or reference of the cell at the intersection of a particular row and column, in a given range
MATCH(lookup_value;lookup_array; [match_type])
Returns the relative position of an item in an array that matches a specified value
COUNTIF(range,criteria)
Counts the number of cells within a range that meet the given condition
LARGE(array,k)
returns the k-th largest number in this data set.
ROW(reference)
returns the row number of a reference
Related posts:
Select 6 unique and random numbers from 1 to 49 (Lottery) in excel
Create random dates, Mon to Fri, within a year in excel
Sort a list in random order in excel
Create a random playlist in excel
How to create random numbers, text strings, dates and time values


















How to transpose it into colomn?
Fajar,
Array formula in B2:
Cell A2 is empty. Copy cell B2 to cell range C2:O2.
@ Oscar
Thank you for your quick reply.
Your suggestion is definitely work.
Thank you.
The sample file works in Excel 2003 while pressing F9, but if using F2 and ctrl+shift+enter on B3 for example, the result is #VALUE! even if not changing anything.
Formula evaluation shows in Step 5: RANDBETWEEN(1,{10}) with 10 in {} that evaluates to #VALUE.
As a workaround, I've added the first function that came to mind (SUM) to change the array with 1 item to a single value.
RANDBETWEEN(1,SUM(ROW(A1)))
Hallo, What if my number of rows will vary and I do not want to manually change the formula on different sheets?
Adell,
Array formula in cell B5:
You still have to adjust one cell range (bolded).
Thank you. I managed to get it working with using the Index and And function, pointing to my "count' value of maximum number required and it works like a charm!
I have some official user list which i want to use in random page number wise like attached example.
Please help me asap.
https://lh4.ggpht.com/1vrCVTerrixozegO8AyvQzUd7SNCWPeCv1oHKRUbJbIZ3UodpI_U8LdnvUs75yWPD3lanbc=s160
I have tried changing this formula to give me a random list of numbers from 1-189 but it doesn't work. Ideally what I want is a grid 15 by 27 full of numbers from 1-405. I was going to use this formula to give a list and paste them into my grid. Can anyone help?
mATT
Array formula in cell A2:
Copy cell A2 and paste to cell range A3:A190.
See attached file:
unique-random-list-of-numbers-1-189.xls
I cannot seem to configure this formula to draw from an adjustable range taken from two cells.
Ex: I want a list of unique random numbers between whatever is entered in cell A4(Min) and B4(Max).
Any help would be greatly appreciated.
Array formula in cell B3:
See attached file:
unique-random-list-of-numbers-will.xls
Thank you Oscar. This only seems to work if the minimum is very low. Once you reach a minimum number>6 it begins to have problems. I am hoping to begin with numbers in the 1000-3000 range.
I wonder if you are seeing a similar problem?
Will,
you are right!
See attached file:
unique-random-list-of-numbers-will2.xls
This is brilliant Oscar. Thank you.
Thanks for this tip, but for some weird reason I still got a few duplicates. Is there a simple method to generate unique random numbers in a column?
I have a list of 1000 names in column A, and would like to generate unique integer numbers in column B for each of those names.
Thanks
My guess is that the cell reference (bolded below) is not changed.
=LARGE(ROW($1:$10)*NOT(COUNTIF($B$2:B2,ROW($1:$10))),RANDBETWEEN(1,11-ROW(A1)))
The array formula above is entered in cell range B3 and down as far as needed.
If you enter the formula in cell D4 and downwards, you must change the cell reference to $D$3:D3, like this:
=LARGE(ROW($1:$10)*NOT(COUNTIF($D$3:D3,ROW($1:$10))),RANDBETWEEN(1,11-ROW(A1)))
Hi Will,
This is a formula I used, the formula was in B3 down to B45 (teh length of my worksheet), the maximum was calcultated in B1, that is the formula revers to B1.
Hope it helps
{=LARGE(ROW(INDIRECT("$1:$"&B$1))*NOT(COUNTIF($B$2:B2,ROW(INDIRECT("$1:$"&B$1)))),RANDBETWEEN(1,B$1+1-ROW(B1))))}
Hi Will,
This formula i just posted, calculted, unique random numbers between 1 and X. Where the maksimum (X)changed on every schedule. My minimum is fixed at 1, but you can change the minimum to refer to a cell that indicated the minimum value/qty.
Good luck
Hi Adell,
I am having trouble changing the minimum value to anything but 1. It has a tendency to result in #NUM! or 0.
EX for 10-20 if B1=20:
{=LARGE(ROW(INDIRECT("$10:$"&B$1))*NOT(COUNTIF($B$2:B2,ROW(INDIRECT("$10:$"&B$1)))),RANDBETWEEN(10,$B$1+1-ROW(B1)))}
Can you tell me what I am doing wrong?
Thanks for all the help!
Hi Will,
The #num is usually, because you did not 'activate' the "string", that is the "{ }" in the beginning and end of the formula. Because there is more than one formula/statement that needs to be "true", before the calculation is done,you need to 'tell' excel to do 'all'. To do this (old fashioned way) you need to go to the beginning of your formula, before the "=" and hold down CTRL + SHFT + ENTER, then the "{}" will appear.
I had a look at the formula and have entered the minimum value into E2.
{=(LARGE(ROW(INDIRECT("$"&E$2&":$"&B$1))*NOT(COUNTIF($B$2:B2,ROW(INDIRECT("$"&E$2&":$"&B$1)))),RANDBETWEEN(E$2,B$1+1-ROW(B1))))}.
see the indirect sections as well as the randbetween part, where it stipulated the minimum and maximum values.
hope this helps, if not, shout
(I don't know if you can obtain my email address from the webmaster if you need to contact me directly) (I am in RSA and will be going offline within the next hour - weekend! - and will only be back on Monday)
Adell
Will,
I also see that on your formula, you 'left out' the first and last set of brackets, that also might be part of your initial error.
=RANDBETWEEN(TIME(8,0,0),TIME(9,45,0))
i have to maintain random time between this nut is is not working
mayur,
randbetween works only with whole numbers.
Try this: =RAND()*(TIME(9,45,0)-TIME(8,0,0))+TIME(8,0,0)
Hi Frnd,
I want to get a random value between 1-20 but I not able to make any sucess ,I used the formula [=LARGE(ROW($1:$20)*NOT(COUNTIF($A$1:A1,ROW($1:$20))),RANDBETWEEN(1,21-ROW(A1)))]
But it is not working.Please help me...
Manoj,
your formula works, did you enter it as an array formula?
I tried on various systems with above code but i still get same error as below :
#NUM!
Please help me as it is very urgent for me.
Hi,
How to do tht or how do i make an array, because i tried as u guided above , please help me as it is very urgent
Hi ,
in your initial formula, you have "[". it should be "{". enter your formula, without the brackets before the "=" and the end one. Then, go to the beginning of your formula, to the left of the "=" and simultaneously press Ctrl Shft Enter . the "{" brackets will appear and your value will appear. (formula will work)
Hi,
I have done asu said but i get the error as: #VALUE!
and do not get the number ,please help
I used the below formula:
{=LARGE(ROW($1:$20)*NOT(COUNTIF($A$1:A1, ROW($1:$20))),RANDBETWEEN(1,21-ROW(A1)))}
Hi,
I have taken your formula, above and copied and pasted it into a new spreadsheet. took out the "{" and "}" and redid the CTRL SHFT ENTER to create the array/string formula and it works om my schedule. The only thing, that might through you out is the space between the comma and "ROW". go to the following link: http://speedy.sh/aMyaR/a.xlsx
You should be able to open it and see your formula working.
cheesh!.. sorry, it should be "throw you out" .... auto correct...
Hi ,
in your initial formula, you have "[". it should be "{". enter your formula, without the brackets before the "=" and the end one. Then, go to the beginning of your formula, to the left of the "=" and simultaneously press Ctrl Shft Enter . the "{" brackets will appear and your value will appear.
Hi,
I have done asu said but i get the error as: #VALUE!
and do not get the number ,please help
I used the below formula:
{=LARGE(ROW($1:$20)*NOT(COUNTIF($A$1:A1, ROW($1:$20))),RANDBETWEEN(1,21-ROW(A1)))}
Manoj,
Did you manage to download the spreadsheet I uploaded? Are your formula now working?
Adell,
Thank you for yor support but I'm sorry as when I click on the given link from u ,I get security error n the the downlod link closes n not allowing me to download the file . Is it possible for you sir to mail me the file on the following email id : manoranjan.tiwari@bt.com
Regards
Manoj
Hi Adell,
Is it possible to make a randome number set thro entire sheet: i tried the following formula :
[=LARGE(ROW($1:$65535)*NOT(COUNTIF($C$1:C1,ROW$1:$65535))),RANDBETWEEN(1,65536-ROW(C1)))]
but it seems not working:
whenever i try to edit your formulla n ammmend it according to my own chice , it gives error as "#NUM!" and when i pres ctrl+shift+enter , it gives this error "#VALUE!" , can you pls explain wht needs to be done to do it or can you pls make for me and send on : manoranjan.tiwari@bt.com
Thanks in advance.
Manoj,
You have a typo in your formula:
=LARGE(ROW($1:$65535)*NOT(COUNTIF($C$1:C1, ROW($1:$65535))), RANDBETWEEN(1, 65536-ROW(C1)))
I tried your formula and it works but it is extremely slow. Do you have to use formulas?
Also remember that the formula creates unique distinct random numbers. If you are looking for only random numbers use this:
=randbetween(0, 65535)
How can I make it start at 0? i.e. random numbers from 0 to 10?
=randbetween(0,10)
Can you try that? I tried that beforehand and it doesn't work for me.
Why would 1,11 be 1-10 and 0,10 be 0 to 10?
I also want to have them lower down than rows 2-11 but can't make that work either. I tried changing the ROW($1:$10) bits but doesn't seem to work.
me,
try this formula in cell B3:
[...] An array formula taken from here..... How to create a list of random unique numbers in excel | Get Digital Help - Microsoft Excel resource [...]
[...] A couple of links that may help you: Learn Excel 2010 - "Random with No Repeats": Podcast #1471 - YouTube How to create a list of random unique numbers in excel | Get Digital Help - Microsoft Excel resource [...]
I've 30 objects and 10 people, and I need to assign each person with randomly (unique) selected objects as a daily activity. Would you please suggest me on how I can do it using excel formulae?
Vijay,
See this post: Assign each person with randomly unique objects as a daily activity
[...] Vijay asks: [...]