Checkbox
Draw a Checkbox | Refer to Checkbox in your Code
An Excel VBA checkbox is a field which can be checked to store information. Learn how to draw a checkbox on your worksheet and how to refer to a checkbox in your code.
Draw a Checkbox
Excel 2010 and Excel 2007 users. Click on Insert from the Developer tab and then click on Check Box in the ActiveX Controls section.

Excel 2003 users. Click on Check Box from the Control ToolBox.

1. Draw a checkbox on your worksheet.

2. You can change the caption of the checkbox by right clicking on the checkbox and then clicking on Properties and Caption (make sure Design Mode is selected).
3. You can change the name of the checkbox by right clicking on the checkbox and then clicking on Properties and Name. For now, we will leave Checkbox1 as the name of the checkbox.
Refer to Checkbox in your Code
To refer to a checkbox in your Excel VBA code, execute the following steps:
1. Right click on the checkbox. Click on View Code. Add the following code lines:
If CheckBox1.Value = True Then Range("C2").Value = 1
If CheckBox1.Value = False Then Range("C2").Value = 0
End Sub
2. Exit the Visual Basic Editor and check the checkbox.
Result:

Although in some situations it can be useful to directly place a checkbox on your worksheet, a checkbox is particularly useful when placed on a Userform.
Did you find this information helpful? Show your appreciation, vote for us.
Go to Top: Checkbox | Go to Next Topic: Option Buttons