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.

1.Picture

This property is used to set the picture for the checkbox control

2.PicturePosition

This property is used to set the position of the picture.

3.Triple state

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.

  1. Private Sub CheckBox1_Change()
  2. If CheckBox1.Value = True Then
  3. MsgBox "Checked"
  4. Else
  5. MsgBox "Not Checked"
  6. End If
  7. End Sub
  8. excel vba checkbox control

excel vba checkbox control

 

You can find similar Excel Questions and Answer hereunder

1) Here an explanation about list box and how to control list boxes in Excel VBA

2) Here an explanation about text box and how to control text boxes in Excel VBA

3) What are ActiveX controls in VBA. Here some good explanations

4) Here an explanation about frames and how to control frames in Excel VBA

5) Here an explanation about spin button and how to control it using VBA

6) Here an explanation about the options in button control in Excel VBA

7) Here an explanation about label controls in the various forms and controls using VBA

8) Here an explanation about buttons in VBA

9) Here an explanation about combo boxes and interfacing with your user in Excel VBA

10) How to control forms in Excel VBA

 

Here the previous and next chapter