Hi guys,
I'm new here and am fairly new to VBA. I have a problem and I don’t know how to solve it in VBA. I have spent some time thinking about this and have so far not got any help on the net.
I am basically creating a questionnaire style program where the user gets asked 50 questions, one by one and they input their answer and press another button (submit button). They initially press a start button to start the questionnaire.
So far, I have created a range of questions and it fills one row where the questions are entered. In intend to use a for loop to go though all 50 questions.
Now this is where I’m stuck. I have a submit button and after each question is displayed, I want the user to enter their answer and then click the submit button to then continue to the next question.
However, I can’t think of how to do this.
1. Firstly, how can I loop through the questions and yet allow the user to input their answers after each iteration?
2. Also can I even click the submit button during the loop phase? I.e. when already running.
Here is the for loop I have:
Any help on this is much appreciated. I’m guessing I need some of Boolean for when the button is pressed but don’t know how to incorporate it into my code. I also want a clear button so that the user can reset their answer if they mess it up. But I’m hoping this solution will help me with that.![]()
Public Sub AskQuestions() For QuestionNo = 1 To 50 Worksheets("test").Range("D11:E11").ClearContents Worksheets("test").Range("B11").Value = QuestionNo Worksheets("test").Range("C11").Value = QuArray(QuestionNo) 'check submit button as been pressed Exit For Next QuestionNo End Sub
Thanks,
FJ
Bookmarks