From: Grimwadec on
For doing golf draws I wish to create a vba function that will generate all
the numbers in a given range in random order, e.g. say 5 players with a
resultant random order of 4,1,5,3,2

The following only gives me one number at a time
Function GenNumbers()

Dim RandomInt

Randomize

RandomInt = Int(((20 - 1 + 1) * Rnd) + 1)

Result = RandomInt

End Function

and the following only gives the numbers in terms of Rnd function

Function LoopGenNumbers()

Dim sngR As Single
Randomize

For A = 1 To 10
sngR = Rnd()

Debug.Print sngR * Rnd()
Next A

End Function

Help please

--
Grimwadec
From: Daniel Pineault on
Try something like that found at

http://www.ozgrid.com/VBA/RandomNumbers.htm

You'll have to comment out the Application.Volatile line (Excel command)
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"Grimwadec" wrote:

> For doing golf draws I wish to create a vba function that will generate all
> the numbers in a given range in random order, e.g. say 5 players with a
> resultant random order of 4,1,5,3,2
>
> The following only gives me one number at a time
> Function GenNumbers()
>
> Dim RandomInt
>
> Randomize
>
> RandomInt = Int(((20 - 1 + 1) * Rnd) + 1)
>
> Result = RandomInt
>
> End Function
>
> and the following only gives the numbers in terms of Rnd function
>
> Function LoopGenNumbers()
>
> Dim sngR As Single
> Randomize
>
> For A = 1 To 10
> sngR = Rnd()
>
> Debug.Print sngR * Rnd()
> Next A
>
> End Function
>
> Help please
>
> --
> Grimwadec