Last Updated on January 11, 2023 by token
How to insert VBA CheckBox control in Excel Sheet (ActiveX control)?
How to use VBA Check Box ? You can embed this control in Excel in the same way as the option buttons. The important thing compare to the VBA option button is that you can select more than one option using Check box. The Check Box selected by the user returns True Value. Unselected Check Box field returns False value. You can choose Check box control from insert icon in Developer’s Tab.
You can change the text of check box field in simple way. After inserting, go right-click to Properties window and change the value in the Caption field and enter your text.
How to insert VBA CheckBox control in VBA UserForm (ActiveX control)?
If you want to use Check Box control in VBA UserForm, all you have to do is open VB Editor and insert Check Box from ToolBox window while UserForm is open.
Programming VBA Check Box (ActiveX control)
How do I put the value of the CheckBox to the VBA code? As I said, the check box value when selected is True. Let’s try to program them using the If Then Else conditional statement. Try to insert three check boxes in Excel Sheet. Insert Also Command Button. When everything is done, click your command button in Design Mode and enter the code:
Private Sub CommandButton1_Click()MsgBox "Your skills:"
If CheckBox1 = True Then
MsgBox "Excel"
End If
If CheckBox2 = True Then
MsgBox "VBA"
End If
If CheckBox3 = True Then
MsgBox "Python"
End If
End Sub
VBA Check Box Properties
In Command Button properties window you can edit many parameters of checkbox, that you inserted into Excel Sheet or User Form. You can change for example:
- (name) – name using in programming Check Box
- Caption – Text written on the check box
- Font – Font and text style
- Colors
- Position
Ok, now you already know how to use VBA Check Box in a simple way. More examples of Excel VBA basics can be found in the Excel VBA Course section and Excel VBA Examples section.