View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default enable/disable start button on basis of chkbox conditions

Assuming that the button is called cmdStart

Option Explicit

Private mEnableEvents As Boolean

Private Sub CheckBox1_Click()
With Me
If mEnableEvents Then
mEnableEvents = False
mEnableEvents = False
.CheckBox2.Value = .CheckBox1.Value
.CheckBox3.Value = .CheckBox1.Value
.CheckBox4.Value = .CheckBox1.Value
.CheckBox5.Value = .CheckBox1.Value
.cmdStart.Enabled = True
mEnableEvents = True
End If
End With
End Sub

Private Sub CheckBox2_Click()
With Me
If mEnableEvents Then
SetCheckboxes .CheckBox2
End If
End With
End Sub

Private Sub CheckBox3_Click()
With Me
If mEnableEvents Then
SetCheckboxes .CheckBox3
End If
End With
End Sub

Private Sub CheckBox4_Click()
With Me
If mEnableEvents Then
SetCheckboxes .CheckBox4
End If
End With
End Sub

Private Sub CheckBox5_Click()
With Me
If mEnableEvents Then
SetCheckboxes .CheckBox5
End If
End With
End Sub

Private Sub UserForm_Activate()
mEnableEvents = True
Me.cmdStart.Enabled = False
End Sub

Private Sub SetCheckboxes(thisCb As MSForms.CheckBox)
With Me
mEnableEvents = False
If Not thisCb.Value Then
.CheckBox1.Value = False
.cmdStart.Enabled = False
ElseIf .CheckBox2.Value And .CheckBox3.Value And _
.CheckBox4.Value And .CheckBox5.Value Then
.CheckBox1.Value = True
.cmdStart.Enabled = True
End If
mEnableEvents = True
End With
End Sub





--
HTH

Bob Phillips

"ilyaskazi" wrote
in message ...

I hv various chkboxes on my userform.

If any of this chkbox value is true then enable the "START" button else
disable.

Plz note: One chkbox is to select and deselect all other chkboxes. Also
if any other chkbox value

is set to false, then the chkbox(select-deselect all) becomes false.

Example file is attached with codes of selecting/deselecting all. I
required now this to reflect

accordingly to "Start" button to enable/disable.


+-------------------------------------------------------------------+
|Filename: Book3.zip |
|Download: http://www.excelforum.com/attachment.php?postid=3451 |
+-------------------------------------------------------------------+

--
ilyaskazi
------------------------------------------------------------------------
ilyaskazi's Profile:

http://www.excelforum.com/member.php...o&userid=23969
View this thread: http://www.excelforum.com/showthread...hreadid=376218