Inserting a checkbox in Excel sounds like a trivial thing, but it opens up a host of new possibilities for your worksheets that will keep you on track with your goals, schedule, assignments, etc. To insert a checkbox in Excel, execute these steps: On the Developer tab, in the Controls group, click Insert, and select Check Box under Form Controls. Click in the cell where you want to insert the first checkbox (B2 in this example). To properly position the check box, hover your mouse over it.
Notes: To enable the Developer tab, follow these instructions:. In Excel 2010 and subsequent versions, click File Options Customize Ribbon, select the Developer check box, and click OK. In Excel 2007, click the Microsoft Office button Excel Options Popular Show Developer tab in the Ribbon. To add a check box, click the Developer tab, click Insert, and under Form Controls, click. To add an option button, click the Developer tab, click Insert, and under Form Controls, click.
Click in the cell where you want to add the check box or option button control. Note: The size of the option button inside the control and its distance from its associated text cannot be adjusted. To format a control, right-click the control, and then click Format Control.
In the Format Control dialog box, on the Control tab, you can modify any of the available options:. Checked: Displays an option button that is selected. Unchecked: Displays an option button that is cleared. In the Cell link box, enter a cell reference that contains the current state of the option button. The linked cell returns the number of the selected option button in the group of options. Use the same linked cell for all options in a group.
The first option button returns a 1, the second option button returns a 2, and so on. If you have two or more option groups on the same worksheet, use a different linked cell for each option group. Use the returned number in a formula to respond to the selected option. For example, a personnel form, with a Job type group box, contains two option buttons labeled Full-time and Part-time linked to cell C1. After a user selects one of the two options, the following formula in cell D1 evaluates to 'Full-time' if the first option button is selected or 'Part-time' if the second option button is selected.
![Checkbox For Excel Checkbox For Excel](/uploads/1/2/5/5/125509486/459727779.png)
=IF(C1=1,'Full-time','Part-time') If you have three or more options to evaluate in the same group of options, you can use the or functions in a similar manner. Deleting a control. Right-click the control, and press DELETE.
. VBA ActiveX CheckBox Control on the UserForm.
Go To Developer Tab and then click Visual Basic from the Code or Press Alt+F11. Go To Insert Menu, Click UsereForm. Please find the screenshot for the same. Drag a check box on the Userform from the Toolbox. Please find the screenshot for the same.
Now, you can see the following code. Private Sub CheckBox1Click End Sub Note: In the above code ‘CheckBox1’ is the Check box name. Please add the following statements to the procedure. Private Sub CheckBox1Click If UserForm2.CheckBox1.Value = True Then MsgBox 'Checkbox has Checked', 'Checkbox' Else MsgBox 'Checkbox has UnChecked', 'Checkbox' End If End Sub.
Run the above macro by pressing F5. Check and uncheck the check box twice to get the two different outputs. Add dynamic CheckBox Control on the UserForm using VBA Please find the following steps and example code, it will show you how to add dynamic checkbox control on the userform. Add command button on the userform from the toolbox. Right click on the command button, click properties.
Change the command button caption to ‘CreateCheckbox’. Double click on the command button.
Now, it shows following code. Private Sub CommandButton1Click End Sub. Call the below procedure named ‘AddDynamicCheckbox’ and find the below procedure to run. Private Sub CommandButton1Click Call AddDynamicCheckbox End Sub Procedure to call in the Command Button: Sub AddDynamicCheckbox 'Add Dynamic Checkbox and assign it to object 'Cbx' Set Cbx = UserForm2.Controls.Add('Forms.CheckBox.1') 'Assign Checkbox Name Cbx.Caption = 'Checkbox2' 'Checkbox Position Cbx.Left = 10 Cbx.Top = 10 End Sub.
![Checkbox Checkbox](/uploads/1/2/5/5/125509486/709841318.png)
Now, click F5 to run the macro, click ‘CreateCheckbox’ button to see the result. You can see the created dynamic check box in the following screen shot.
Output: Select or UnSelect a CheckBox using VBA? Please find the below code to know how to select or UnSelect a check box using VBA. In the below example we are using value property of the check box to select or UnSelect a check box. ‘ To select check box CheckBox1.Value=True ‘ To unselect check box CheckBox1.Value=False Check if a check box is selected or not using VBA Please find the below code to know how to check if a check box is selected or not using VBA. In the below example we are using value property of the check box.
Sub ChkBoxEx1 If CheckBox1.Value = True Then MsgBox “CheckBox has selected” Else MsgBox “CheckBox has not selected” End If End Sub More details about Check box control Here is the link more about how to add check box control on the Worksheet or UserForm in Excel. Here is the one more link to more about how to add check box control on the Worksheet or UserForm using VBA in Excel. Here is the one more link to more about how to remove check box control on the Worksheet or UserForm in Excel.