+ Reply to Thread
Results 1 to 18 of 18

Help with "bingo" spreadsheet

  1. #1
    Registered User
    Join Date
    12-15-2008
    Location
    Johannesburg
    Posts
    23

    Help with "bingo" spreadsheet

    Hi

    I'm your average excel user (I can record a macro and use most common functions).

    Recently, being bored, I developed a sudoku solver spreadsheet and a lotto spreadsheet that I showed off to all and sundry.

    Now my girlfriend has challenged me to come up with a Bingo spreadsheet. Well, I've tried . . .But I don't think you do it with functions, and I'm not savvy enough to do it with code.

    Basically, in Bingo you have 89 numbers. I need to display 1 number at a time randomly chosen from the 89 available, but I must display each number only once, and therefore I must do it a maximum of 89 times to display all 89 numbers.

    I can generate the random numbers (obviously), but I'm stuck as to how to display each number only once.

    Please help!!
    Thank you
    Last edited by Riley_5000; 12-23-2008 at 07:21 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    CPearson has created a solution for this very thing. Read up on it here. Let us know how it goes.

    http://www.cpearson.com/excel/RandomNumbers.aspx (Getting An Array Of Unique, Non-Duplicated Values)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    12-15-2008
    Location
    Johannesburg
    Posts
    23
    Thanks, I'll give it a try

  4. #4
    Registered User
    Join Date
    12-15-2008
    Location
    Johannesburg
    Posts
    23
    I've had a look at it. Unfortunately, it returns a range of non - duplicate values between 2 numbers you specify. This isn't quite right . . .

    I need to display just one number, and that one number musn't be repeated until I've gone through all 89.

    It's very tricky. I initially wrote a code which generates a random number (randbetween(1,89)), vlookups that number in my table (1 - 89), and then deletes the number from my list. Well, that certainly worked, except that as more numbers got deleted, more vlookups returned blank.

    Please help??

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Post up what you did and let's see what's up. You're supposed to be able to generate any number of random numbers you want, including all 89.

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon Riley_5000

    I've written a bingo type game - you can find it on my add-in (see the link below). I found that the easiest way to do this, is write a little routine that will generate all numbers first, pile them all into an array, and then start going through the array one by one.

    Have a look at the code below - it does just that and then flash each one up in a MsgBox. It might be just enough to get you going :

    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Just put the 89 numbers in random order (or use Chip's routine) in some hidden place, and then index them one at a time.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    To create a non-duplicating set of random numbers, I typically use the RAND() (which rarely will produce a duplicate) and then Rank them. See attachment. Is this a good starting point for you?
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  9. #9
    Registered User
    Join Date
    12-15-2008
    Location
    Johannesburg
    Posts
    23
    Thanks everybody, I'll give all of this a try.

    I've deleted my pathetic attempt, however I can rewrite this week and post it if anybody's curious

  10. #10
    Registered User
    Join Date
    12-15-2008
    Location
    Johannesburg
    Posts
    23
    I've tried them all, DOMINI CB came the closest - however, the numbers still occasionally repeat!

    I think this should go up on the challenge board.
    How about this:
    You generate a random number bet 1 & 89, place that number into a table, and then have the code check the table and keep generating numbers until it gets one that isn't there. And then repeat until table is full . . .

    That probably requires code - which is not my forte. Can somebody help, or do you think we should put this up on the challenge board??

  11. #11
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Riley_5000
    Quote Originally Posted by Riley_5000 View Post
    I've tried them all, DOMINI CB came the closest - however, the numbers still occasionally repeat!
    Are you sure you have some repeats?

    I have just replaced the last three lines before the "End Sub" statement with this :
    Please Login or Register  to view this content.
    This will place the 90 numbers starting from row 1 in whatever column is active. I ran the macro 10 times in all and each time I got a perfect set of the numbers 1 - 90 in random order.

    HTH

    DominicB

  12. #12
    Registered User
    Join Date
    12-15-2008
    Location
    Johannesburg
    Posts
    23
    yeah, i tried the column code dominic, and checked it for unique values and it always returns a perfect 90. Weird. If u generate just one number at a time and write them down, then after 10 or 20
    Numbers u get a repeat. . . I understand ur code, but something's just a little bit. . . . I'm going to try it with just functions, wil u help me with vba, dominic?

  13. #13
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Riley
    Quote Originally Posted by Riley_5000 View Post
    If u generate just one number at a time and write them down, then after 10 or 20
    Numbers u get a repeat. . . . I'm going to try it with just functions, wil u help me with vba, dominic?
    I've just used my original code to go through an entire sequence from 1 to 90 twice without a single skip or duplicate. Twp p[erfect runs - exactly as you'd expect if writing them straight to a spreadsheet works. They're from exactly the same array so the two routines couldn't possibly produce different results. Once the routine has been run the numbers are in there.

    Of course, I'll continue to help as much as I can whether you use my suggestion or one of the others, as will anyone else who drops back in on this thread.

    I don't know if you tried downloading the add-in, but if you want the module and userform that drives the bingo game then I can forward this in a workbook for you. If so PM me your e-mail address.

    HTH

    DominicB

  14. #14
    Registered User
    Join Date
    12-15-2008
    Location
    Johannesburg
    Posts
    23
    Ok, I'm not sure how to PM . . .

    Anyway, attached is what I've done with your column code. Just hit f9
    Attached Files Attached Files

  15. #15
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    works for me! (ps how do you increase the range to say 1000?)

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Here's one ...
    Last edited by shg; 01-07-2009 at 12:17 PM.

  17. #17
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Revision A ...
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    12-15-2008
    Location
    Johannesburg
    Posts
    23
    just change all the 90's to 1000 in the code, and then if u look in column A you will hav 2 continue the sequence all the way to 1000. Thanks dominic

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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