How do you randomly generate numbers in Excel 2007?

  • Thread starter Thread starter Steve Bedard
  • Start date Start date
S

Steve Bedard

How do you randomly generate numbers from 1 to 84 without duplicates in Excel
2007?
 
Hi,

the question isn't clear but try this. Select the cells you want the numbers
in and run this code. Because you are in the range 1 to 84 you mest selevt 84
cells or less

Sub Unique_Rands()
Dim FillRange As Range
Set FillRange = Selection
For Each c In FillRange
Do
c.Value = Int((84 * 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.
 
Well..., I don't know how much of a "gambler" you are - but as a "Gimmick"
you are invited to try the proposal in the picture.
Any cell - in range F1:F84 must be blank.
An "X" points that that value was generated more than once.
Cells A1, B1 and F1 should be copied down all the way until row 84.
http://img717.imageshack.us/img717/5083/nonamesi.png
Micky
 
Back
Top