S
Steve C
Our company is tracking participation in health & nutrition events. I have
setup a spreadsheet listing the employee name in column A, and the number of
events participated in in column B. The list of employees may grow as more
participate. To reward them, we want to do a random drawing for prizes,
based on weighted participation. For example, if each employee's name below
were placed in a fishbowl, Employee01 would be added seven times, Employee02
three times, etc.
Employee01 7
Employee02 3
Employee03 1
Employee04 4
Employee05 2
Employee06 2
Employee07 2
Employee08 1
Employee09 3
Employee10 1
I wrote the following code (attached to a command button) to randomly pick a
winner based on one entry per employee, but how can I use the number of
events in column B to weight the results in favor of greater participation?
Thanks for any help you can offer!
Range("A1").Select 'cell containing first employee name
Range(Selection, Selection.End(xlDown)).Select 'select all listed employees
MyCount = Selection.Cells.Count 'captures count of employees listed
Range("D1").FormulaR1C1 = "=RANDBETWEEN(0," & MyCount & ")" 'produces a
random number between 0 and total number of employees
WinnerNum = Range("D1").Value 'captures the number generated
Range("A1").Select
Winner = ActiveCell.Offset(WinnerNum, 0).Value 'captures name of winning
employee
Range("D2").Value = Winner
setup a spreadsheet listing the employee name in column A, and the number of
events participated in in column B. The list of employees may grow as more
participate. To reward them, we want to do a random drawing for prizes,
based on weighted participation. For example, if each employee's name below
were placed in a fishbowl, Employee01 would be added seven times, Employee02
three times, etc.
Employee01 7
Employee02 3
Employee03 1
Employee04 4
Employee05 2
Employee06 2
Employee07 2
Employee08 1
Employee09 3
Employee10 1
I wrote the following code (attached to a command button) to randomly pick a
winner based on one entry per employee, but how can I use the number of
events in column B to weight the results in favor of greater participation?
Thanks for any help you can offer!
Range("A1").Select 'cell containing first employee name
Range(Selection, Selection.End(xlDown)).Select 'select all listed employees
MyCount = Selection.Cells.Count 'captures count of employees listed
Range("D1").FormulaR1C1 = "=RANDBETWEEN(0," & MyCount & ")" 'produces a
random number between 0 and total number of employees
WinnerNum = Range("D1").Value 'captures the number generated
Range("A1").Select
Winner = ActiveCell.Offset(WinnerNum, 0).Value 'captures name of winning
employee
Range("D2").Value = Winner