Check Status of all Checkboxes

JTL9IRON

New Member
Joined
Nov 3, 2005
Messages
31
I have 32 checkboxes on a userform for Yes/No answers to 16 questions.
Question 1 Checkbox 1 for yes Checkbox 2 for no...etc.
Each yes/no checkbox adds a value to a cell on active spreadsheet.

When the user in done (in their mind anyways) They click a command button to enter another person responses. Right now the CB clears all the checkboxes and moves 1 line down on the spreadsheet for the next person.

In that code attached to the command button I want it to check to make sure at least 1 response to each question has been chosen.

If checkbox1.value = false and checkbox2.value = false then Msgbox "You did not answer question 1"

I created this same code for all 16 questions.

The user corrects the missing answer(s) and clicks the CB again to enter another person responses. Here is where my code stops. Once it has veified that at least 1 repsonse was chosen for each question I need to reset the checkboxes and go on to the next person answers.

I haven't done VB in sometime so my code is pretty simplistic and I've probably typed 16 lines for something that more advance code would replace in 1.

I hope I explained this well enough for you to understand. :confused:

Thanks for reading
Jamie (Connecticut/USA) :p
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Can you post your curent code?

ou can cycle through all the controls on a userform like this.
Code:
Dim ctl
     
     For Each ctl In Me.Controls ' Me is a reference to the form
          ' do something with the control ctl
     Next
You could test within the loop for the type or name of the control.
 
Upvote 0
Sorry for the delay in getting back. Here is the section of the code that I have tied to the Command Button when you want to enter another persons responses. I was looking for the code to check for any missing answers and if there are any put up a msg box stating which one(s) then when all completed resetting the checkboxes to false. The checkboxes were putting values in cells in the worksheet.

If CheckBox1.Value = False And CheckBox2.Value = False Then MsgBox "You forgot to answer question 1/2", vbOKOnly, "Missing Answer"
If CheckBox3.Value = False And CheckBox4.Value = False Then MsgBox "You forgot to answer question 3/4", vbOKOnly, "Missing Answer"
If CheckBox5.Value = False And CheckBox6.Value = False Then MsgBox "You forgot to answer question 5/6", vbOKOnly, "Missing Answer"
If CheckBox7.Value = False And CheckBox8.Value = False Then MsgBox "You forgot to answer question 7/8", vbOKOnly, "Missing Answer"
If CheckBox9.Value = False And CheckBox10.Value = False Then MsgBox "You forgot to answer question 9/10", vbOKOnly, "Missing Answer"
GoTo missing
If CheckBox1.Value = True Or CheckBox2.Value = True Then GoTo missing
If CheckBox3.Value = True Or CheckBox4.Value = True Then GoTo missing
If CheckBox5.Value = True Or CheckBox6.Value = True Then GoTo missing
If CheckBox7.Value = True Or CheckBox8.Value = True Then GoTo missing
If CheckBox9.Value = True Or CheckBox10.Value = True Then GoTo missing

CheckBox1.Value = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
CheckBox5.Value = False
CheckBox6.Value = False
CheckBox7.Value = False
CheckBox8.Value = False
CheckBox9.Value = False
CheckBox10.Value = False

TextBox1.SetFocus
Application.Goto Reference:="R[1]C[]"
TextBox1.Text = ""
missing:
End Sub

Thanks again for your help[/code]
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

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