Você está na página 1de 4

# http://www.get-digital-help.

com/2009/07/03/how-to-create-a-random-list-of-unique-
numbers-in-excel/
How to create a list of random unique numbers in excel
Question: How do ! create a random list of unique numbers from sa" # to #0\$ without using
%&':
(enerate unique random numbers
)nique random numbers in %&'
and without enabling iterati*e calculation in excel options and not using +helper+ columns,
Formula in cell A2:
-!./01234'552!6278).9!62:':#:'#\$ ;8<2:#::#0==-0\$ ;8<2:#::#0=\$ ++=\$
;8<2!./!;0792+#:+>3)42!6278).9!62:':#:'#\$ ;8<2:#::#0==-0\$ #\$ 0=====\$
;8)./2;'./2=?3)42!6278).9!62:':#:'#\$ ;8<2:#::#0==-0\$ #\$ 0==\$ 0=\$ = @ 79;5 @
3H!69 @ 0.90; copied down to cell '#A.
UPDATE:
Alternative array formula in A2:
-5';(02;8<2:#::#0=?.89278).9!62:':#:'#\$ ;8<2:#::#0===\$
;'./&09<00.2#\$##-;8<2'#=== @ 79;5 @ 3H!69 @ 0.90;.
7op" cell '2 and paste down as far as needed.
Explaining the alternative array formula in cell A2
Step 1 - Create an array
;8<2:#::#0= creates this arra" B#\$ 2\$ 3\$ A\$ C\$ D\$ 7\$ E\$ 9\$ #0F
Step 2 - Create a criterion to avoid duplicate numbers
78).9!62\$A\$1:A1\$ ;8<2:#::#0== maGes sure no duplicate numbers are created. 9he
formula has both absolute and relati*e cell references 2\$A\$1:A1=. <hen the formula are
copied down to cell '3 the cell reference changes to :':#:'2. 9he *alue in cell '2 canHt be
randoml" selected again.
!n cell '2\$ 78).9!62\$A\$1:A1\$ ;8<2:#::#0== creates this arra": B0\$ 0\$ 0\$ 0\$ 0\$ 0\$ 0\$ 0\$ 0\$ 0=
Step 3 - Create a ne dynamic array
;8<2:#::#0=?.89278).9!62:':#:'#\$ ;8<2:#::#0=== creates this arra" in cell '2: B#\$
2\$ 3\$ A\$ C\$ D\$ 7\$ E\$ 9\$ #0F
!f the arra" formula randoml" selects the number 2 in cell '2\$ the formula in cell '3 creates
this arra": B#\$ 0\$ 3\$ A\$ C\$ D\$ 7\$ E\$ 9\$ #0F
.umber 2 canHt be selected an"more.
Step ! - Calculate the number range in "andbeteen#bottom\$ top%
9he bottom *alue is alwa"s #. 9he top *alue changes depending on current cell.
!n cell '2 the top *alue is #0.
!n cell '3 the top *alue is 9
and so on..
6ormula in cell '2: ##-;8<2'#= equals #0. 2##-#-#0=
6ormula in cell '3: ##-;8<2'2= equals 9. 2##-2-9=
and so on..
Step & - Create a random number
-5';(02;8<2:#::#0=?.89278).9!62:':#:'#\$ ;8<2:#::#0===\$
RANDBETWEEN(111!R"W(A1##=
;'./&09<00.2#\$##-;8<2'#==
becomes
;'./&09<00.2#\$##-#=
becomes
;'./&09<00.2#\$#0=
and returns a random number between # and #0.
Step ' - Select a random number in array
-5';(02;8<2:#::#0=?.89278).9!62:':#:'#\$ ;8<2:#::#0===\$
;'./&09<00.2#\$##-;8<2'#===
becomes
-5';(02B#\$ 2\$ 3\$ A\$ C\$ D\$ 7\$ E\$ 9\$ #0F\$ ;'./&09<00.2#\$#0==
becomes
-5';(02B#\$ 2\$ 3\$ A\$ C\$ D\$ 7\$ E\$ 9\$ #0F\$ random_number= and returns a random number
between # and #0.
How to customize array formula to your excel work sheet
!f "our list starts at 63 change :':#:'# to :6:2:62 in the abo*e arra" formula. 9o change the
numbers from # to #0 to\$ for example\$ 2 to #2\$ change :#::#0 to :2::#2 also in the abo*e
arra" formula.
Iress 69 to generate a new random list of unique numbers.
Downloa\$ e%cel sam&le 'ile 'or t(is tutorial)
uni*ue!ran\$om!list!o'!num+ers)%ls
20xcel 97-2003 <orGbooG ?.xlsx=
Functions in t(is article:
,NDE-(arra"\$rowJnum\$KcolumnJnumL#
;eturns a *alue or reference of the cell at the intersection of a particular row and column\$ in a
gi*en range
.AT/0(looGupJ*alueMlooGupJarra"M KmatchJt"peL=
;eturns the relati*e position of an item in an arra" that matches a specified *alue
,F(logicalJtestMK*alueJif:trueLMK*alueJifJfalseL#
7hecGs whether a condition is met\$ and returns one *alue if 9;)0\$ and another *alue if
6'530
/"UNT,F(range\$criteria#
7ounts the number of cells within a range that meet the gi*en condition
1U.(number#\$Knumber2L\$#
'dds all the numbers in a range of cells
1.A22(arra"\$G# returns the G-th smallest row number in this data set.
R"W(reference# returns the rownumber of a reference
,ND,RE/T(refJtext\$Ka#L#
;eturns the reference specified b" a text string