UK Bingo cards

craigey1

New Member
Joined
Apr 6, 2020
Messages
30
Office Version
  1. 2019
Platform
  1. Windows
Apologies for asking for so much help on my very first post here.

I've been searching all over for a solution to be able to produce a UK style bingo card within Excel using formulas or VBA, but so far have only found code that's capable of producing singular games rather than a set of 6. I've searched here & seen that the question has been asked before, but so far no-one seems to have been able to come up with a solution. I thought I could look at randbetween() to generate the necessary numbers for each column, but couldn't see how to then comply the required game layout rules. I really don't know where to start with this. I'd normally try & then ask for help when stuck, so here I am!

The UK bingo games use numbers 1 to 90 (including 90) with the numbers split across 6 games of 3 rows by 9 columns. The number 1 to 9 would appear in the first column, 10 to 19 in column 2, 20 to 29 column 3 & so on until the 9th column which also includes the number 90. All numbers would only appear once across all 6 of the games & each box has 5 blanks across each row & can have 0, 1 or 2 blanks per column.
In summary:
1. A bingo 'card' is a set of 6 individual 3 x 9 grids, stacked vertically, which contain the numbers 1-90
2. The numbers 1 - 9 (9 numbers) are in the first column and 80-90 (11 numbers) in the 9th, the intervening columns (2-8) contain 10 numbers each.
3. An individual box has 15 numbers, 5 per row and between 0 and 2 per column

I'd appreciate any help with this as was hoping to generate cards for friends / family during the lockdown.

thanks in advance

jumbobingoticket-jpg.10662
 

Attachments

  • JumboBingoTicket.jpg
    JumboBingoTicket.jpg
    119 KB · Views: 3,418

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Interesting, and not sure if I will get it but looks like a good challenge.
Question...
Is it possible that a cardhave a column with 3 numbers in it and anotehr columne has 0 numbers in it
 
Upvote 0
Sorry can't seem to edit the post - Originally post says:
3. An individual box has 15 numbers, 5 per row and between 0 and 2 per column
but it should say between 1 and 2 per column
 
Upvote 0
check the following site to see if the ideas help
I've given that a go & managed to get a 3 * 9 grid populated with the appropriate numbers. I got 2 cards to be generated from the same numbers table, but a 3rd always produced a NUM! error on all but the last column - I suspect due to the additional number 90 in the table.

I'm not sure how I'd then go about adding in the blank spaces or how to generate the additional cards using the unused numbers or how to reuse the numbers that would be covered over when inserting the blanks.
 

Attachments

  • num_table.jpg
    num_table.jpg
    182 KB · Views: 58
  • bcard.jpg
    bcard.jpg
    126.7 KB · Views: 58
Upvote 0
Hello craigey1
I never tried to create the Bingo cards. I just recalled that Debra had an example on her site.
If you are still having troubles, you can post an example with XL2BB. Please describe your problem and
explain what is different in your sheet compared to Debra's.

Hopefully someone will be able to answer your questions.
 
Upvote 0
TBH I thought the screenshots would help with clarifying the issue. The formula on the link you provided uses INDEX / Match & all I've done it adjusted the cell vales it looks for.
Anyway here goes:
Cards sheet has:
Cell Formulas
RangeFormula
B12:B14,B7:B9,B2:B4B2=INDEX(Numbers!$A$1:$A$9,MATCH(LARGE(Numbers!$B$1:$B$9,ROW()-1),Numbers!$B$1:$B$9,0))
C12:C14,C7:C9,C2:C4C2=INDEX(Numbers!$D$1:$D$10,MATCH(LARGE(Numbers!$E$1:$E$10,ROW()-1),Numbers!$E$1:$E$10,0))
D12:D14,D7:D9,D2:D4D2=INDEX(Numbers!$G$1:$G$10,MATCH(LARGE(Numbers!$H$1:$H$10,ROW()-1),Numbers!$H$1:$H$10,0))
E12:E14,E7:E9,E2:E4E2=INDEX(Numbers!$J$1:$J$10,MATCH(LARGE(Numbers!$K$1:$K$10,ROW()-1),Numbers!$K$1:$K$10,0))
F12:F14,F7:F9,F2:F4F2=INDEX(Numbers!$M$1:$M$10,MATCH(LARGE(Numbers!$N$1:$N$10,ROW()-1),Numbers!$N$1:$N$10,0))
G12:G14,G7:G9,G2:G4G2=INDEX(Numbers!$P$1:$P$10,MATCH(LARGE(Numbers!$Q$1:$Q$10,ROW()-1),Numbers!$Q$1:$Q$10,0))
H12:H14,H7:H9,H2:H4H2=INDEX(Numbers!$S$1:$S$10,MATCH(LARGE(Numbers!$T$1:$T$10,ROW()-1),Numbers!$T$1:$T$10,0))
I12:I14,I7:I9,I2:I4I2=INDEX(Numbers!$V$1:$V$10,MATCH(LARGE(Numbers!$W$1:$W$10,ROW()-1),Numbers!$W$1:$W$10,0))
J12:J14,J7:J9,J2:J4J2=INDEX(Numbers!$Y$1:$Y$11,MATCH(LARGE(Numbers!$Z$1:$Z$11,ROW()-1),Numbers!$Z$1:$Z$11,0))


Numbers sheet has:
Cell Formulas
RangeFormula
Z1:Z11,W1:W10,T1:T10,Q1:Q10,N1:N10,K1:K10,H1:H10,E1:E10,B1:B9B1=RAND()
 
Upvote 0
You can use the code below. You can speed it up a bit by turning screenupdating off, but I kind of liked the effect of the code running through the cards.

20200407 MXL Bingo.xlsm
ABCDEFGHIJ
15243649707787Card 1
2182160
3233465162
46164273Card 2
52239556575
691534586985
7144482Card 3
81017293141576381
9285979
10122738437486Card 4
112048566484
124256672
1334588Card 5
141323377690
151194047546171
1681126355053677883Card 6
17325268
187308089
Sheet2


VBA Code:
Sub Main()
Dim AR() As Variant: ReDim AR(1 To 18, 1 To 9)
Dim AVAIL As Object: setAvail AVAIL
Dim NUMS As Object: setNums NUMS
Dim SP() As String
Dim Card As Integer, Spot As Integer, rNum As Integer
Dim CD As Integer: CD = 9
Dim Col As Integer: Col = 1
Dim b As Boolean: b = False

Do
    Do Until Col > 9
        Card = AVAIL.keys()(getRand(AVAIL.Count - 1, 0))
        Do
            SP = Split(AVAIL(Card), "-")
            Spot = getRand(SP(1), SP(0))
        Loop Until AR(Spot, Col) = vbNullString
        rNum = getRand(CD, 0)
        AR(Spot, Col) = NUMS(rNum)
        If Not checkCard(AR, SP(1), SP(0), Col) Then AVAIL.Remove Card
        NUMS.Remove NUMS(rNum)
        CD = CD - 1
        If CD < 0 Then
            CD = 9
            setAvail AVAIL
            Col = Col + 1
        End If
    Loop
    Range("A1:I18") = AR
    If Not finalCheck Then
        Reset AVAIL, NUMS, AR, Col, CD
    Else
        b = True
    End If
Loop Until b = True
       
End Sub

Sub Reset(ByRef AVAIL As Object, ByRef NUMS As Object, ByRef AR() As Variant, ByRef Col As Integer, ByRef CD As Integer)
setAvail AVAIL
setNums NUMS
Col = 1
CD = 9
ReDim AR(1 To 18, 1 To 9)
Range("A1:I18").ClearContents
End Sub

Function getRand(hi As Variant, lo As Variant) As Integer
getRand = Int(((hi + 1) - lo) * Rnd() + lo)
End Function

Sub setAvail(ByRef AVAIL As Object)
Set AVAIL = CreateObject("Scripting.Dictionary")
Dim id As Integer: id = 0
For i = 0 To 17 Step 3: AVAIL.Add id, Join(Array(i + 1, i + 3), "-"): id = id + 1: Next i
End Sub

Sub setNums(ByRef NUMS As Object)
Set NUMS = CreateObject("System.Collections.ArrayList")
For i = 1 To 90: NUMS.Add i: Next i
End Sub

Function checkCard(ByRef AR() As Variant, hi As Variant, lo As Variant, Col As Integer) As Boolean
Dim total As Integer: total = 0
For i = lo To hi
    If AR(i, Col) <> vbNullString Then
        total = total + 1
    End If
Next i
checkCard = total < 2
End Function

Function finalCheck() As Boolean
Dim r As Range
Dim b As Boolean: b = True
ActiveSheet.UsedRange.Interior.ColorIndex = -4142
For Ro = 1 To 18 Step 3
    For Col = 1 To 9
        Set r = Range(Cells(Ro, Col), Cells(Ro + 2, Col))
        If Application.WorksheetFunction.CountBlank(r) = 3 Then finalCheck = False: Exit Function
    Next Col
Next Ro
finalCheck = b
End Function
 
Upvote 0
You can use the code below. You can speed it up a bit by turning screenupdating off, but I kind of liked the effect of the code running through the cards.
....

Thanks - I haven't had a chance to look through this yet, but it looks like it could be just the job. Very much appreciated, Sir!
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top