VBA code to print lottery tickets base on the cell amount.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
Good Day,
With below code TextBox5 data is the amount of the tickets supposed to be given to the visitors for a ruffle.
I will be additional code to print those tickets base on TextBox5 data ("E2") which base on below target worksheet cells.
The frame I've prepared base on below cells A to D
Many Thanks.



Worksheet Name: PRINT
A2: Visitors ID#
B2: Name & Surname
C2: Date

D2: Day

E2: Total tickets amount to be printed!



VBA Code:
Private Sub CommandButton2_Click()

On Error Resume Next
Dim asy As Long
With Sheets("All Data")
If .Cells(1, 1).Value = "" Then
asy = 1
Else
asy = .Cells(Rows.Count, 1).End(xlUp).Row + 1
End If

.Cells(asy, 1) = TextBox1.Value
.Cells(asy, 2) = TextBox2.Value
.Cells(asy, 3) = TextBox3.Value
.Cells(asy, 4) = TextBox4.Value
.Cells(asy, 5) = TextBox5.Value
End With
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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