+ Reply to Thread
Results 1 to 14 of 14

Weighted Random Number Generator for Raffle

  1. #1
    Registered User
    Join Date
    01-21-2013
    Location
    NYC
    MS-Off Ver
    Excel 2003
    Posts
    4

    Weighted Random Number Generator for Raffle

    Hi there,

    I am trying to create a raffle in excel but no luck so far. I have about 200 people in the raffle, all with multiple entries ranging from 1-150 or so. My data currently looks like this:

    Column A: Names of participants
    Column B: Number of entries

    I would like to create a function that helps pick a winner for 5 different prizes, with no participant being able to win more than 1 prize.

    I hope something like this is possible. Let me know if any additional information is helpful. I am new to this.

    Thanks in advance.

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Weighted Random Number Generator for Raffle

    So John may have three tickets and Jane may have two, etc.?
    Gary's Student

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Weighted Random Number Generator for Raffle

    Here's one way...

    A3:A50= names
    B3:B50 = number of chances

    In C3 enter 1

    Enter this formula in C4 and copy down to C50:

    =B3+C3

    To pick the winners...

    Enter this formula in E2:

    =INDEX(A3:A50,MATCH(RANDBETWEEN(1,SUM(B3:B50)),C3:C50))

    Now, delete the row of the winner. The formula will recalculate and choose a new winner. Repeat this 4 more times to get all 5 unique winners.
    Last edited by Tony Valko; 10-03-2013 at 09:06 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Weighted Random Number Generator for Raffle

    Here is a macro-based solution.
    The raw data is in columns A & B.
    A full weighted table is produced in column D.
    Five random non-repeating picks are made and the winners posted in column E
    Macros must be enabled for this to work!
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-21-2013
    Location
    NYC
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Weighted Random Number Generator for Raffle

    Hi thanks! I think the macro will help. Again, new to macros, but how can I edit it to show the results one row down?

  6. #6
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Weighted Random Number Generator for Raffle

    To place the five winners one row down, replace:

    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-21-2013
    Location
    NYC
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Weighted Random Number Generator for Raffle

    Thanks! This is great! Is there a way to have a delay between the display of each line/winner? So that line 5 would appear, then line 4, and so forth.

    Thanks again for all the help!

  8. #8
    Registered User
    Join Date
    01-21-2013
    Location
    NYC
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Weighted Random Number Generator for Raffle

    Hi again,

    Is there a way to have a delay between the display of the results? Thanks!

  9. #9
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Weighted Random Number Generator for Raffle

    Check back tomorrow!

  10. #10
    Registered User
    Join Date
    10-29-2014
    Location
    Florida
    MS-Off Ver
    MS Office
    Posts
    1

    Re: Weighted Random Number Generator for Raffle

    This is exactly what I needed! Thanks a Mil!

  11. #11
    Registered User
    Join Date
    11-19-2014
    Location
    US
    MS-Off Ver
    2013
    Posts
    2

    Re: Weighted Random Number Generator for Raffle

    Hello I hope you can still answer a question or two for me. First let me say what you got is great! I need to have the possibility to draw the same person more than once. I also want to be able to either pause the macro before the winners are picked or at least split the macro so only the table is filled and then another button is used to pick the winners (i want to randomize the entries in col D before picking winners). The raffle is 2000-3000 tickets and there will be a wide variation of ticket holdings ie. (1 person has 1 ticket while another has 500) i really don't want 500 entries in order together. I know every little about macro scripting and have been messing around, can get the full table to work alone but can't pick winners in a separate macro (I imagine because certain variables aren't defined, but i'm not sure what to change/add). Thanks.

  12. #12
    Registered User
    Join Date
    01-07-2019
    Location
    Bangor
    MS-Off Ver
    10
    Posts
    1
    I realize I'm necroing this post but is there a way that instead if 5 winners there could instead be 20 or 30? I cant seem it fugure it out without redoubg the formula all over again. Im just looking to see if someone can point me in the right direction on where i can edit to either add or remove winners.

  13. #13
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Weighted Random Number Generator for Raffle

    I will take a look later today.

  14. #14
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,051

    Re: Weighted Random Number Generator for Raffle

    decihex welcome to the forum

    Unfortunately your post does not comply with Rule 4 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 06-21-2013, 10:40 AM
  2. [SOLVED] Weighted Random Number Generator Code Needed
    By BenGT in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-24-2012, 02:09 PM
  3. Need Random Number Generator but with Weighted Probability for Certain Numbers...
    By michaeljoeyeager in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-13-2012, 03:52 PM
  4. Need Help with a Random Number Generator with Weighted Probability for Certain Numbers
    By michaeljoeyeager in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2012, 02:48 PM
  5. Random number generator
    By sweetjonnycrash in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2010, 02:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1