Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel Random number from a set of options

In MS Excel, how can I randomly calculate a number number that is from one of a set of 5 options?

For example, in cell B1 I would like to have a random number that is either 15,30,50,75, or 100.

I would like a completely random output of these 5 numbers in cells B1:B100.

I was thinking that I could generate a random number in cell A1 using rand, then using a series of > or < IF statements to output only one of these numbers above.

like image 790
Ryan Avatar asked Apr 25 '13 19:04

Ryan


2 Answers

This formula will do it:

=CHOOSE(RANDBETWEEN(1,5),15,30,50,75,100)

If you want to use a range of cells:

=INDEX($B$2:$B$6,RANDBETWEEN(1,5))
like image 135
Doug Glancy Avatar answered Jan 11 '23 06:01

Doug Glancy


A quick and easy way would be to first make a lookup list like this:

enter image description here

Then in your column do a formula like this:

=VLOOKUP(ROUND(RAND()*10,0),$A$7:$B$16,1,FALSE)

where the $A$7:$B$16 is where your list is at. It can be on a different tab, or separate file, if you really need to isolate it.

You could also create a custom VBA function too, but I think that is beyond what you are looking for.

like image 38
Alan Waage Avatar answered Jan 11 '23 04:01

Alan Waage