Tuesday, 1 April 2014

MS EXCEL ACTIVX CHECKBOX CODING

To add activx check box in Microsoft Excell then follow below simple steps:

1. Enable developer tab in Microsoft Excel

Goto: File → Option → Customize Ribbon → Main Tabs → select “Developer” → Ok


2. Goto: developer tab in top ribbon → insert → active x → check box









3. Activate Design Mode and Right click on check box and “view code”







View Code will show below code.

Private Sub CheckBox1_Click()
End Sub

4. Add below lines in between of above code.


If CheckBox1.Value = True Then
    CheckBox2.Value = False
    CheckBox3.Value = False
   End If
5. If you group multiple check boxes and want to one must be activated then add below code for three checkboxes as a group.
Private Sub CheckBox1_Click()
   If CheckBox1.Value = True Then
       CheckBox2.Value = False
       CheckBox3.Value = False
   Else:
       CheckBox2.Value = True
   End If
End Sub
Private Sub CheckBox2_Click()
   If CheckBox2.Value = True Then
       CheckBox1.Value = False
       CheckBox3.Value = False
   Else:
       CheckBox3.Value = True
   End If
End Sub
Private Sub CheckBox3_Click()
   If CheckBox3.Value = True Then
       CheckBox1.Value = False
       CheckBox2.Value = False
   Else:
       CheckBox1.Value = True
   End If
End Sub

No comments:

Post a Comment