Table of Contents

Check Box

A check box is a field which can be checked to store information. To create a check box in Excel VBA execute the following steps.

1. On the Developer tab click Insert.

2. In the ActiveX Controls group click Check Box.

Create a check box in Excel VBA

3. Drag a check box on your worksheet.

4. Right click the check box (make sure Design Mode is selected).

5. Click View Code.

View Code

Note: you can change the caption and name of a control by right clicking on the control (make sure Design Mode is selected) and then clicking on Properties. Change the caption of the check box to MyCheckBox. For now we will leave CheckBox1 as the name of the check box.

6. Add the following code lines:

If CheckBox1.Value = True Then Range(“D2”).Value = 1
If CheckBox1.Value = False Then Range(“D2”).Value = 0

7. Click the check box on the sheet (make sure Design Mode is deselected).

Result:

Check Box True

Check Box False

Although in some situations it can be useful to directly place a check box on your worksheet a check box is particularly useful when placed on a Userform.

Leave A Comment

Excel meets AI – Boost your productivity like never before!

At Formulas HQ, we’ve harnessed the brilliance of AI to turbocharge your Spreadsheet mastery. Say goodbye to the days of grappling with complex formulas, VBA code, and scripts. We’re here to make your work smarter, not harder.

Related Articles

The Latest on Formulas HQ Blog