Bingo Draw No duplicates

wayne0881

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

I found a video on youtube that draws bingo numbers with no repeats so I simply copied the Macro code by hand, the first part works and creates a random set of numbers the second part however is coming back with an error.

This part works fine:

Sub StartOver()
Cells.Clear
Range("E1") = "Number"
Range("F1") = "Sort"
Range("E2") = 1
Range("E2:E91").DataSeries Step:=1
Range("F2:F91").Formula = "=Rand()"
End Sub


This part doesn't - this button is the bingo number draw button

Sub DrawUnique()
Range("F1").CurrentRegion.Sort Key1:=Range("F1"), Header:=xlYes
Range("E100").End(xlUp).Copy_
Destination:=Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Range("E100").End(xlUp).Resize(1, 2).Clear
End Sub

Destination line is the problem as it is highlighted in Yellow in excel? I am no VBA/Macro expert hence why I just copied it from the video -

https://www.youtube.com/watch?v=QGQ1Hox20VY

I have included the video above - thanks for any help :)
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Maybe:

Code:
Sub DrawUnique()
Range("F1").CurrentRegion.Sort Key1:=Range("F1"), Header:=xlYes
Range("E100").End(xlUp).Copy Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Range("E100").End(xlUp).Resize(1, 2).Clear
End Sub
 
Upvote 0
Change "_" to " _". IT is the line continuation character.

I normally indent the next line so that I can visually see that structure. e.g.
Code:
Sub StartOver()
    ActiveSheet.UsedRange.Clear
    Range("E1") = "Number"
    Range("F1") = "Sort"
    Range("E2") = 1
    Range("E2:E91").DataSeries Step:=1
    Range("F2:F91").Formula = "=Rand()"
End Sub

Sub DrawUnique()
    Range("F1").CurrentRegion.Sort Key1:=Range("F1"), Header:=xlYes
    Range("E100").End(xlUp).Copy _
        Destination:=Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
    Range("E100").End(xlUp).Resize(1, 2).Clear
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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