PDA

View Full Version : How to do randomized draw with excel



The Cosworth
01-06-2009, 12:48 PM
I am running a draw at my office for some hockey tickets. I have the names compiled in an excel sheet.

is there any way to dump it into a program that will do a randomized draw on it?

I dont want to print them off, cut them and then throw them in a hat.

adam c
01-06-2009, 12:53 PM
=rand()
or
=randbetween(smallest,highest)

then hit F9 a couple times with your head turned away

edit. this is for a random number btw, but if you can script you can turn it into something different, but it really isn't worth the time to make something for a one time use

assign the employees a number then you get a result

The Cosworth
01-06-2009, 01:00 PM
haha, you sir are a genius

adam c
01-06-2009, 01:02 PM
btw if =randbetween gives you #name? you need to install the analysis tool pack

Tools > Add Ins > Select the toolpacks > OK

The Cosworth
01-06-2009, 01:14 PM
Originally posted by adam c
btw if =randbetween gives you #name? you need to install the analysis tool pack

Tools > Add Ins > Select the toolpacks > OK

no it works great, it is too bad you cant randomize the cells to have the peoples names just show up. But having a single cell that shows a number that corresponds to their location on the sheet isn't that much different.

edit: i just did =randbetween(1,18) the number of people who have entered.

Works out quite well

ercchry
01-06-2009, 01:17 PM
could you do a if command? like if cell=# then display **

The Cosworth
01-06-2009, 01:18 PM
Originally posted by ercchry
could you do a if command? like if cell=# then display **

i dont think it would be an if would it? some sort of reference command, even maybe a true/false command.


edit: just tried an if, it would work but you would have to have as many as you would have people. You have to reference it then do an if command I guess.

adam c
01-06-2009, 01:33 PM
you can but it would require VBS which wouldn't be useful unless you plan on using this sheet over and over again

nonlinear
01-06-2009, 01:44 PM
Originally posted by The Cosworth


no it works great, it is too bad you cant randomize the cells to have the peoples names just show up. But having a single cell that shows a number that corresponds to their location on the sheet isn't that much different.

edit: i just did =randbetween(1,18) the number of people who have entered.

Works out quite well

haha, this is possible using if you uyse the if and and commands. (ie. display a name in a particular cell if the number associated with that name is the same as the 'random' number). but that is just really dorky and the extra work isn't worth it, unless you're doing this at a party or something and want some silly showy thing on a projector or somehting.

but if you're THAT into it, you can do some reading and find out that =RAND function doesn't actually produce random numbers at all!

nonlinear
01-06-2009, 01:52 PM
Originally posted by The Cosworth


i dont think it would be an if would it? some sort of reference command, even maybe a true/false command.


edit: just tried an if, it would work but you would have to have as many as you would have people. You have to reference it then do an if command I guess.

if would definitely work, and you could get the winning name to appear in a particular cell. there are several ways you could do it, using if, and, etc. etc.

you could have e.g. a column of numbers (e.g. 1-14) adjacent to a column of names - each number corresponding to a name. then, generate a number within 1-14 and it will display in a cell. then, using if statement you can ask if each number in the column next to names is equal to the 'random' number, and if so to display the associated name. you could do if commands in a column, in a cascading fashion so that the ultimate cell will display the text from the cell containing the if statment adjacent to the winners name

it's kinda hard to explain in words.

as someone else mentioned, you could also use the visual basic included in excel (alt + f11 to open it). you can do all kinds of crazy things in vba, and it's really simple. you can even make fancy looking buttons in excel spreadsheet that will execute your code when you press them, which might be cool if you're doing this at a party or somethign. let me know if y9oiu need help

adam c
01-06-2009, 01:53 PM
like i said it's more time than it's worth for one draw

nonlinear
01-06-2009, 01:58 PM
^^^haha yea totally. you really only want to do it if you're totally nerdcore, or maybe if you're doing some kind of fuynny presentation where you want to show it on a screen

The Cosworth
01-06-2009, 02:07 PM
if I get slow I may try and work this out. I just volunteer on our social committee and am running this weeks draw, and didnt want to cut the shit out and do a hat draw.

haha

thanks for all your help