View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
vezerid
 
Posts: n/a
Default How to generate #'s that excludes certain numbers?

There are several ways. One way is to use two columns: In column K:K
(say starting from K2) you enter all the admissible numbers. Then, one
column before, type 0 in J2 and then in J3 type =J2+1/48 and copy all
the way to J49.

Then, to generate random numbers use:
=VLOOKUP(RAND(), $J$2:$K$49,2)
This will produce your numbers with equal probability.

Another, not so precise formula:
=IF(RAND()<2/48, 1+INT(RAND()*2), IF(RAND()<20/48, 4+INT(RAND()*20),
25+INT(RAND()*26)))

HTH
Kostis Vezerides