Randbetween Function

  • Thread starter Thread starter Dominique Feteau
  • Start date Start date
D

Dominique Feteau

Can i be more specific on what random numbers Randbetween chooses?

Like it can choose any number between 1-26, but not 1,2,4,5,9 and 26.

Don't ask why cuz its tooooo complicated.

Thanx

niq
 
Hi
I would create my own UDF to achieve this and filter our the not
desired results in a loop within this function. Though I'm not sure if
the resulting random numbers are still uniform distributed?
But for your purpose it should be sufficient. So you may try

Public Function my_random() As Integer
Dim ret_value
Dim test
While Not test
ret_value = Int(26 * Rnd + 1)
If ret_value = 1 Or ret_value = 2 _
Or ret_value = 4 Or ret_value = 5 _
Or ret_value = 9 Or ret_value = 26 Then
test = False
Else
test = True
End If
Wend
my_random = ret_value
End Function

call it in your worksheet with
=MY_RANDOM()
 
Would something along this idea work?

=INDEX({3,6,7,8,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25},RANDBETWEEN
(1,20))
 
Back
Top