Flash Cards
A simple VBA script to make Flash Cards
1. Open Excel. Save as Flashcards.xls
Fill in 10 Questions and 10 Answers in the range of A1:B10 of a worksheet
You may start with duummy data. See picture below.
2. Create a button in a worksheet.
Paste this VBA code for the button
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
3. Create a Module
Paste in this code for the module
Global X As Integer
4. Create a UserForm using labels, text boxes and commands buttons as below
5. Paste the following VBA code in the UserForm through the Visual Basic Editor
Private Sub UserForm_Initialize()
X = 0
End Sub
Private Sub CommandButton1_Click()
X = X - 1
If X < 1 Then X = 1
TextBox1.Value = Range("A" & X)
TextBox2.Value = Range("B" & X)
End Sub
Private Sub CommandButton2_Click()
X = X + 1
If X > 10 Then X = 10
TextBox1.Value = Range("A" & X)
TextBox2.Value = Range("B" & X)
End Sub
Private Sub CommandButton3_Click()
X = 1
TextBox1.Value = Range("A" & X)
TextBox2.Value = Range("B" & X)
End Sub
Private Sub CommandButton4_Click()
X = 10
TextBox1.Value = Range("A" & X)
TextBox2.Value = Range("B" & X)
End Sub
Private Sub TextBox1_Enter()
X = X + 1
TextBox1.Value = Range("A" & X)
TextBox2.Value = ""
End Sub
Private Sub TextBox2_Enter()
If X = 0 Then X = 1
TextBox2.Value = Range("B" & X)
End Sub
6. Add another 10 questions and answers to the worksheet for a total of 20.
Modify the code to include all 20 questions.
| Attachment | Size |
|---|---|
| FlashCards2.xls | 39.5 KB |
| FlashCards3.xls | 66.5 KB |