Validating checkboxes

G

Guest

Hi All,
I have an Excel sheet that has several checkboxes. I also have a command
button that when clicked the form is emailed. When the user clicks the
cammand button I need to verify that at least one checkbox in each category
is checked before the form is emailed. I tried something like:

If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value =
False And CheckBox36.Value = False And CheckBox38.Value = False Then

MsgBox "Please check reason for request!"
Range("A11").Select

End If

I receive the msgbox, but when I click ok, the form is emailed even though
there isn't any checkboxes checked. I think I need code after the msgbox
line but I am not sure how to do this. Can someone help me?
 
G

Guest

See change below.

If CheckBox1.Value = False _
And CheckBox2.Value = False _
And CheckBox3.Value = False _
And CheckBox36.Value = False _
And CheckBox38.Value = False Then

MsgBox "Please check reason for request!"
Range("A11").Select
Exit sub '<<<<<Add this
End If
 
G

Guest

Thanks! Works great.

JNW said:
See change below.

If CheckBox1.Value = False _
And CheckBox2.Value = False _
And CheckBox3.Value = False _
And CheckBox36.Value = False _
And CheckBox38.Value = False Then

MsgBox "Please check reason for request!"
Range("A11").Select
Exit sub '<<<<<Add this
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top