T
The Rook
I am wanting to generate random numbers from 1 to 20 in cells A1 to A20, but
have no duplicates.
How can I do this?
have no duplicates.
How can I do this?
You can use this macro
Sub Liminal()
Dim FillRange As Range
Set FillRange = Range("A1:A20")
For Each c In FillRange
Do
c.Value = (20 * Rnd) + 1
Loop Until WorksheetFunction.CountIf(FillRange, c.Value) < 2
Next
End Sub
When competing hypotheses are otherwise equal, adopt the
hypothesis that introduces the fewest assumptions while still
sufficiently answering the question.
The Rook said:I am wanting to generate random numbers from
1 to 20 in cells A1 to A20, but have no duplicates.
How can I do this?
I said:A2:
=SMALL(IF(ISNA(MATCH(ROW(INDIRECT("1:20")),
$A$1:A1,0)), ROW(INDIRECT("1:20"))),
RANDBETWEEN(1,21-ROWS($A$1:A2))) [....]
Note that A2 is an array formula.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.