LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Weighted Random Selection

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

--
Steve C
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random Selection Craig Excel Worksheet Functions 3 September 27th 07 05:18 PM
Proportionally weighted random generator? WildlyHarry Excel Discussion (Misc queries) 3 June 10th 07 04:11 PM
Random function - weighted Periz28 Excel Worksheet Functions 8 August 5th 06 01:19 AM
Dollar weighted rate of return with random cash flows shfigato Excel Discussion (Misc queries) 1 April 26th 06 12:07 AM
Selecting at random with weighted probability Damage Excel Worksheet Functions 2 January 31st 05 11:06 PM


All times are GMT +1. The time now is 11:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"