ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check box in user form (https://www.excelbanter.com/excel-programming/344214-check-box-user-form.html)

raw[_9_]

Check box in user form
 

Hi

I have a user form with 2 check box, but i need help with some code
I want a error message to appear if box boxes are ticked or both are
not

Also how do unload check boxes and option buttons so after closing the
next person using the form has no choice but to select one (this is in
case someone select a option but the next person forgets to and leaves
the option before which is the wrong one for them!!!!) Hope that makes
sense

here is some of my code already

If Not (OptionButton6 Or OptionButton7) Then
MsgBox "No option for job type track only or compelet, please
select."
OptionButton6.SetFocus
Exit Sub

Thanks


--
raw
------------------------------------------------------------------------
raw's Profile: http://www.excelforum.com/member.php...o&userid=28312
View this thread: http://www.excelforum.com/showthread...hreadid=480443


Bob Phillips[_6_]

Check box in user form
 

"raw" wrote in message
...
I have a user form with 2 check box, but i need help with some code
I want a error message to appear if box boxes are ticked or both are
not


Private Sub CheckBox1_Click()
With Me
If .CheckBox1.Value = .CheckBox2.Value Then
MsgBox "Can't both be set/unset"
.CheckBox1.Value = Not .CheckBox2.Value
End If
End With
End Sub

Private Sub CheckBox2_Click()
With Me
If .CheckBox1.Value = .CheckBox2.Value Then
MsgBox "Can't both be set/unset"
.CheckBox2.Value = Not .CheckBox2.Value
End If
End With
End Sub

Trouble with this is that once you set one or other, you can never change it
as any other action triggers the error.

Also how do unload check boxes and option buttons so after closing the
next person using the form has no choice but to select one (this is in
case someone select a option but the next person forgets to and leaves
the option before which is the wrong one for them!!!!) Hope that makes
sense


Public Sub UserForm_Activate()
With Me
.CheckBox1.Value = False
.CheckBox2.Value = False
End With
End Sub




Leith Ross[_157_]

Check box in user form
 

Hello Raw,

You neeed to change the *OR* to *XOR*.

If Not (OptionButton6 Xor OptionButton7) Then

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=48044



All times are GMT +1. The time now is 08:31 PM.

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