Thread: Random Numbers
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Random Numbers

Hi,

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
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"The Rook" wrote:

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?