Search This Blog

Thursday 26 October 2017

ENABLE OR DISABLE CHECKBOX ON CLICK OF ANOTHER CHECKBOX



1) Write the below code on the initialize event of  your userform

Private Sub UserForm_Initialize()
Me.ChildBox1.Enabled = False
Me.ChildBox2.Enabled = False
End Sub

It makes the Child-1 & Child-2 disabled which means only the Parent checkbox will be enabled when the userform initializes.

2) Write the below code on Click event of the Parent checkbox.

Private Sub parentbox_Click()
If Me.parentbox.Value = True Then
Me.ChildBox1.Enabled = True
Me.ChildBox2.Enabled = True
ElseIf Me.parentbox.Value = False Then
Me.ChildBox1.Enabled = False
Me.ChildBox2.Enabled = False
End If
End Sub

It makes the Child-1 and Child-2 enabled when Parent is checked and disabled when Parent is unchecked.

Is the post useful? 

Please put your comments in the comment section and subscribe the blog:) Thank you.