Dim gCheck As String
Private Sub CommandButton1_Click()
'Const UpperBound As Integer = 4
'Const LowerBound As Integer = 3
Dim iRow As Integer
Dim iRowEnd As Integer
Dim vReply As Variant
Dim WS As Worksheet
Set WS = Sheets("Questions")
iRowEnd = WS.Range("A65536").End(xlUp).Row
CommandButton2.Visible = False
If Intersect(Selection, Range("c8:e10")) Is Nothing Then Exit Sub
If Selection.Rows.Count > 1 Then
MsgBox "Please Select 1 Square Only", 0, "Error"
Exit Sub
End If
If Application.CountA(Selection) <> 0 Then
MsgBox "The Square You Have Selected Already Contains A Move", 0, " Error"
Exit Sub
End If
'iRow = Int((UpperBound - LowerBound + 1) * Rnd + LowerBound)
iRow = Int(iRowEnd * Rnd + 1)
If Len(gCheck) = 0 Then gCheck = String(iRowEnd, " ")
If gCheck = String(iRowEnd, "X") Then
MsgBox "All questions asked!"
Exit Sub
End If
Do While Mid$(gCheck, iRow, 1) = "X"
iRow = iRow + 1
If iRow > iRowEnd Then iRow = 1
Loop
vReply = Application.InputBox(prompt:=WS.Range("A" & iRow).Text & "?")
If LCase$(Trim$((vReply))) = LCase$(Trim$(WS.Range("B" & iRow).Text)) Then
MsgBox ("You Answered Correctly")
ActiveCell.FormulaR1C1 = "X"
CommandButton1.Visible = False
CommandButton2.Visible = True
Else
MsgBox ("Sorry Wrong Answer")
CommandButton1.Visible = False
CommandButton2.Visible = True
End If
Mid$(gCheck, iRow, 1) = "X"
Dim sReply As String
sReply = CheckRows
If sReply = "" Then sReply = CheckCols
If sReply = "" Then sReply = CheckDiags
Select Case sReply
Case "X"
[G10] = [c6] & " Wins!"
Range("i11").Value = Range("i11").Value + 1
Range("g8,m8").Value = Range("g8,m8").Value + 1
Range("C8:E10").Select
Selection.ClearContents
Range("C7").Select
Selection.ClearContents
Range("m12").Select
CommandButton1.Visible = True
CommandButton2.Visible = True
Case "O"
[G10] = [E6] & " Wins!"
Range("I8,m9").Value = Range("I8,m9").Value + 1
Range("i11").Value = Range("i11").Value + 1
Range("C8:E10").Select
Selection.ClearContents
Range("C7").Select
Selection.ClearContents
Range("m12").Select
CommandButton1.Visible = True
CommandButton2.Visible = True
Case "*"
[G10] = "Tie!"
Range("H8").Value = Range("H8").Value + 1
Range("i11").Value = Range("i11").Value + 1
Range("C8:E10").Select
Selection.ClearContents
Range("C7").Select
Selection.ClearContents
Range("m12").Select
CommandButton1.Visible = True
CommandButton2.Visible = True
End Select
End Sub