+ Reply to Thread
Results 1 to 18 of 18

Help with "bingo" spreadsheet

Hybrid View

  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 :

    Sub test()
    Dim rand1(90)
    Randomize
    For n = 1 To 90
    Check1:
    rand1(n) = Int((90 * Rnd(100)) + 1)
    For F = 1 To T
    If rand1(n) = rand1(F) Then GoTo Check1:
    Next F
    T = T + 1
    Next n
    For n = 1 To 90
    MsgBox rand1(n)
    Next n
    End Sub
    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??

+ 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