I there a way of using VBA to hit enter or down or select another cell, while a user is editing a cell? I am creating a quiz for children and want to ensure that the child doesn't press enter after typing their answer the code doesn't break.
Sorry if this is unclear I am new to VBA.
I am trying to create a 5 times table quiz for some students. The aim of the macro is to post the question then allow them 6 seconds to answer and then a 3 second rest.
As the user will be children I am hoping to make it as bulletproof as possible. To do this I was planning on the following:
-Most of the sheet will be protected so they can do very little.
-The answer cell is automatically selected so the kids only need to enter the number.
-At the end of the 6 seconds the code kicks them out of the answer cell and answer is checked.
I am struggling with the final bullet, specifically the kicking the students of of the answer cell when they are still editing it. I have tried: Application.SendKeys "{ENTER,False}".
Sub Test()
Dim PauseTime, BreakTime, time1, time2, time3, i
i = 1
Do While i < 13
Sheets("Test_SG").Range("N_1").Value = i
Sheets("Test_SG").Range("N_2").Value = 5
Sheets("Test_SG").Range("Answer").Select
PauseTime = 6 ' Set question duration.
BreakTime = 3 ' Set break duration.
time1 = Timer ' Set start time.
time2 = Timer + PauseTime
time3 = Timer + PauseTime + BreakTime
Do Until time1 >= time2
DoEvents ' Yield to other processes.
time1 = Timer
Loop
Application.SendKeys "{ENTER,False}"
If Sheets("Test_SG").Range("Answer") = i*5 Then
Sheets("Teacher_Zone").Range("Start").Offset(0,i).Value = "Y"
Else
Sheets("Teacher_Zone").Range("Start").Offset(0,i).Value = "N"
End If
Sheets("Test_SG").Range("A1").Select
Do Until time1 >= time3
time1 = Timer
Loop
i = i + 1
Loop
End Sub