Searching a survey for responses using VBA code

nngabert

New Member
Joined
Jan 22, 2018
Messages
2
Hello!
I'm making a survey that requires a response on every question. I have everything coded in VBA so that when an answer is selected on a check box all results are tabulated. However, I'm at a loss as to how I would create a button that interrogates the entire survey to ensure an answer has been selected for every question. If there is a question missing an answer, a message box should pop up. I tried using this IF statement, but it just makes the message box pop up every time I click the command button, whether the check boxes are selected or not.

If (FIVE_fiveAcheck = False And FOUR_fiveAcheck = False And THREE_fiveAcheck = False And TWO_fiveAcheck = False And ONE_fiveAcheck = False And IE_fiveAcheck = False) Then MsgBox "Please select a rating for question 1.a)"

FYI it's ITEM_questionPARTcheck (as in check box)

I figured evaluating each question part (A or B) as a set would be the best way to approach it.
Alternatively, a button that evaluates the whole document for questions without an answer and provides a generic "please answer all questions" would be fine.

Thanks in advance for any help at all! I just started learning VBA yesterday so, much appreciated.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
tabulate each missing answer and only show the popup if the missingans => 1.
In this way you could even keep track of which answers the user didn't answer.

Something like:
Code:
For x = 1 to 50 'example of 50 questions
if trim(answer(x))="" then
missingans = missingans + 1
missingansstr = missingansstr & vbcr & question(x)
endif
next x
if missingans=> 1 then
msgbox "You did not answer " & missingans & " questions:" & vbcr & missingansstr
exit sub 'or go back to the missing answers
endif
 
Upvote 0
Thanks! This seems super useful - especially to put everything into one message box at the end. Could you just explain what exactly each part of that means/does? I'm not sure what I'm supposed to alter to make it fit my code. Please and thx!
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top