ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checkboxes (https://www.excelbanter.com/excel-programming/375514-checkboxes.html)

Tammy H

Checkboxes
 
I have a worksheet that has 5 checkboxes. I used the Contol Toolbox to place
these in the worksheet. How can I make sure the user checks at least one of
the 5 checkboxes? I would like to add the code to a command button that the
user will click when they send the form.



Bob Phillips

Checkboxes
 
Put this code behind the commandbutton

Private Sub CommandButton1_Click()
If Not Me.CheckBox1.Value And _
Not Me.CheckBox2.Value And _
Not Me.CheckBox3.Value And _
Not Me.CheckBox4.Value And _
Not Me.CheckBox5.Value Then
MsgBox "Nothing selected, try again"
Else
'do your stuff
End If
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tammy H" wrote in message
...
I have a worksheet that has 5 checkboxes. I used the Contol Toolbox to

place
these in the worksheet. How can I make sure the user checks at least one

of
the 5 checkboxes? I would like to add the code to a command button that

the
user will click when they send the form.





Susan

Checkboxes
 
(think Horseshack from Welcome Back Kotter)
ooooh! ooooh! i know that one!!!!
:) [with the disclaimer that SOMEBODY probably
knows a better way to do it!]

sub checks() 'untested

If chk1.Value = False And _
chk2.Value = False And _
chk3.Value = False And _
chk4.Value = False And _
chk5.Value = False Then

Msgbox "You must check at least one checkbox!", vbExclamation +
vbOkOnly

Else

'enter code to do if not ALL are unchecked.

End If
End sub

susan



All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com