Bingo Generator code - help please!

wayne0881

Board Regular
Joined
Nov 2, 2009
Messages
95
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone,

I have come across a video online on how to make a bingo generator with a histogram
so you get no repeats and a list of the previous numbers drawn.

In Cells A1-A75 you have the numbers 1-75
In Cells B1-B75 you also have the numbers 1-75
In Cells C1 you have =if(B1="","",RAND()) (copy down to C75)
In Cells D1 you have =if(B1="","",IF(Rank(C1,$C$1:$C$75)>1,"",Row(B1))) (copy down to D75)
In Cell E1 you have =small(D1:D75,1)

In Cells J1-N1 you have the Letters B I N G O
In Cells J2-N16 you have a criss cross box (so each individual cell is in its own box)
this will be the histogram box which tracks the previous numbers drawn.

In Cells J2 you have =IF(B1="",A1,"") Drag Down to J16
In Cells K2 you have =IF(B16="",A16,"") Drag Down to K16
In Cells L2 you have =IF(B31="",A31,"") Drag Down to L16
In cells M2 you have =IF(B46="",A46,"") Drag Down to M16
In cells N2 you have =IF(B61="",A61,"") Drag Down to N16

Ok this is as far as I have got, were it gets beyond me is the following:

In Cells G2-H4 there is a button named Draw ( I do not know how to create buttons)
In Cells G12-H13 there is a button named Reset Game ( again I don't know how to create and install buttons)
In Cells G5-H6 is where the current drawn number is displayed

There is some code used in Visual Basic which looks like this:

Private Sub btnDraw_Click()

Dim linenumber As Interger, numpick As Interger
Dim bingonum As String

linenumber = Range ("E1").Value
numpick = Range("B" & linenumber).Value
Range ("B" & linenumber).ClearContents

If numpick > 60 Then
bingonum = "O " & numpick
ElseIf numpick > 45 Then
bingonum ="G" & numpick
ElseIf numpick > 30 Then
bingonum = "N" & numpick
ElseIf numpick > 15 Then
bingonum = "I" & numpick
Else
bingonum ="B" & numpick
End If

Range ("G5").Value = bingonum

End Sub


Private Sub btnReset_Click()

Dim linenumber As Interger
linenumber = 1

Do

Range("B" & linenumber).Value = Range("A" & linenumber).Value

linenumber = linenumber + 1
Loop Until Range ("A" & linenumber).Value

Range("G5:H6").ClearContents

End Sub

Can somebody please explain how I create the buttons needed for this and what I have to do to get the current number displayed, do I just copy this code into a
Visual Basics and thats it to make it work??

I hope you have all followed along ok... :)
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
There are several very good step-by-step guides, tutorials, and videos showing how to do this. Do a web search for something like
Excel worksheet buttons tutorial

Be aware there are two different types of buttons that can be placed on a worksheet; ActiveX and Form-type. Your code above is for a Form-type button.

Here's one good tutorial, but it's by no means the only one.
Excel VBA Worksheet Macro Buttons
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,512
Members
449,167
Latest member
jrob72684

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