1. On the Developer tab, click Insert.
2. In the ActiveX Controls group, click Check Box.
3. Drag a check box on your worksheet.
4. Right click the check box (make sure Design Mode is selected).
5. Click 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 = 17. Click the check box on the sheet (make sure Design Mode is deselected).
If CheckBox1.Value = False Then Range("D2").Value = 0
Result:
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..