randomizer as study aide

S

sycsummit

I have a massive chart of anatomical connections to memorize thats all saved
in one workbook. I've wasted a lot of paper printing it out and filling it
out but I'm starting to think I'm recognizing terms based on where they are
on the page in relation to other terms and not the actual structures I'm
supposed to be linking them to.

My form is laid out with 5 columns: Muscle, Origin, Insertion, Innervation,
and Action. In the Muscle column, the name of the muscle appears. I need to
memorize the data in the Origin/Insertion/Innervation and Action cells that
go with that particular muscle.

So, here is what I want to do - create a quick form that will randomly
select any cell from (ORIGIN,INSERTION,ACTION or INNERVATION), and allow me
to type in the muscle name, and tell me if i'm correct or incorrect. I'd
like to be able to ask it for a SECOND clue (ie, if I can't guess the
innervation, give me the origin as well) and THIRD clue and FOURTH clue
before revealing the name of the muscle to me.

Then of course once I guess correctly or have it give me the answer I'd like
it to access another muscle name and start over. I don't know how to code
but I have a general basic understanding of excel and this forum has served
me well in the past. Hope it works this time as well!

Thanks!
 
B

Bernie Deitrick

Sycsummit,

Create a user form (userform1) with 5 textboxes (TextBox1 for muscle name, then TextBox2 for
ORIGIN, TextBox3 for INSERTION, TextBox4 for ACTION and TextBox5 for INNERVATION), and use labels to
label the textboxes as to what they are. Add 3 commandbuttons to your userform (and perhaps a
fourth to quit, but you can always just x out of the userform)

Commandbutton1 has code for selecting and showing a new set of values, CommandButton2 for showing
additional clues, and Commandbutton3 for checking your answer that you entered into textbox1, and
starting over again if you are correct, or allowing you to continue to guess if you want.

I've assumed that your list is in columns A to E, of the only sheet in the workbook (the active
sheet) with headers in row 1 and the values down the sheet.

Then use this macro

Sub ShowStudyAide()
Load UserForm1
UserForm1.Show
End Sub

to show the userform and quiz yourself.

HTH,
Bernie
MS Excel MVP


Option Explicit
Dim iRand As Integer
Dim iRandRow As Integer
Dim Answer As String
Dim Clues(2 To 5) As String

Private Sub CommandButton1_Click()
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
Me.TextBox5.Text = ""

'Pick another number between 2 and the last row of your datapoints
iRandRow = 2 + Int(Rnd() * (Cells(Rows.Count, 1).End(xlUp).Row - 1.000001))

'Put out the clue
Answer = Cells(iRandRow, 1).Text
Clues(2) = Cells(iRandRow, 2).Text
Clues(3) = Cells(iRandRow, 3).Text
Clues(4) = Cells(iRandRow, 4).Text
Clues(5) = Cells(iRandRow, 5).Text

'Pick a number between 2 and 5
iRand = 2 + Int(Rnd() * 3.999999)
Me.Controls("Textbox" & iRand).Text = Clues(iRand)

End Sub

Private Sub CommandButton2_Click()
'Pick a number between 2 and 5
Dim iCnt As Integer
Dim i As Integer
For i = 2 To 5
If Me.Controls("Textbox" & i).Text = "" Then
GoTo tryAgain
End If
Next i

MsgBox "All clues have been shown"
Exit Sub

tryAgain:

iRand = 2 + Int(Rnd() * 3.999999)
If Me.Controls("Textbox" & iRand).Text = "" Then
Me.Controls("Textbox" & iRand).Text = Clues(iRand)
Else
GoTo tryAgain:
End If


End Sub

Private Sub CommandButton3_Click()
If TextBox1.Text = Answer Then
MsgBox "Correct!"
Call CommandButton1_Click
Else
If MsgBox("Do you want to guess again?", vbYesNo) = vbNo Then
MsgBox "The correct answer is " & Answer & "."
Call CommandButton1_Click
Else
TextBox1.Text = ""
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top