random number generation

N

nyn04

how would I generate a random number from a list of given numbers i
excel or better yet in vba, sy a I have a list of 1,2,3,4,5 and I wil
like it randomly pick a number

thnank
 
A

AlfD

Hi!

You could use
=INT(RAND()*5)+1
or, if your version of Excel supports it,
=RANDBETWEEN(1,5)

Al
 
J

Jerry W. Lewis

If you only want to generate a single number, or if you don't mind
duplicates, then the previous suggestions should work well. If you want
to randomly select more than one number with no duplicates, put 1:5 in
A1:A5, put =RAND() in B1:B5, then sort A1:B5 by B1:B5 and take however
many numbers you want starting from the resulting A1.

Jerry
 
Top