Vba checkbox control in Excel
This control is used to give users, the facility to select more than one choice of interest.
This usually is used, when there is a need to choose more than one value.
This is generally seen in the websites while creating new accounts.
The checkbox is exact opposite to a optionbutton, where only one selection is possible.
For example, consider a case, when an application requires the user to select the sports of their interest.
The user may be interested in more than one sport.
In such cases, Checkbox is used, where the user can select as many as choices of his interest.
Properties of Checkbox control
The checkbox has the same common properties as discussed in the previous chapters.
Some unique properties of checkbox are as listed below.
This property is used to set the picture for the checkbox control
This property is used to set the position of the picture.
This property is used to specify whether the checkbox can support triple states.
This takes a True or False value.
Events of Checkbox
The Change event is the most common event used with this control.
This event is triggered while Checking/Unchecking a checkbox.
The following code illustrates this:
Note that, for demo purpose, the first checkbox, "Cricket" alone is coded.
- Private Sub CheckBox1_Change()
- If CheckBox1.Value = True Then
- MsgBox "Checked"
- MsgBox "Not Checked"
- End If
- End Sub