REAL-TIME

VBA Projects

Full Access with Source Code
  • Designed and Developed by PNRao

  • Full Access with VBA Source Code

  • Well Commented Codes Lines

  • Creative and Professional Design

Effortlessly
Manage Your Projects

120+ Project Management Templates

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Share Post

CheckBox is one of the UserForm control. You can select and drag CheckBox on the UserForm. CheckBox Control is used to specify or indicate binary choice. That is either Turn on or off a value. When we use more checkboxs, you can select more than one CheckBox at a time on the UserForm. You can select multiple check boxes in a group box. Please find more details about CheckBox Control in the following chapter.

VBA ActiveX CheckBox Control on the UserForm

    1. Go To Developer Tab and then click Visual Basic from the Code or Press Alt+F11.
    2. Go To Insert Menu, Click UsereForm. Please find the screenshot for the same.

Excel VBA UserForm CheckBox

    1. Drag a check box on the Userform from the Toolbox. Please find the screenshot for the same.

AxtiveX Checkbox Control1

    1. Now, you can see the following code.
Private Sub CheckBox1_Click()

End Sub

Note: In the above code ‘CheckBox1’ is the Check box name.

    1. Please add the following statements to the procedure.
Private Sub CheckBox1_Click()
    If UserForm2.CheckBox1.Value = True Then
       MsgBox "Checkbox has Checked", , "Checkbox"
    Else
       MsgBox "Checkbox has UnChecked", , "Checkbox"
    End If
End Sub
  1. Run the above macro by pressing F5.
  2. 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.

    1. Add command button on the userform from the toolbox.
    2. Right click on the command button, click properties
    3. Change the command button caption to ‘Create_Checkbox’
    4. Double click on the command button
    5. Now, it shows following code.
Private Sub CommandButton1_Click()
 
End Sub
    1. Call the below procedure named ‘Add_Dynamic_Checkbox’ and find the below procedure to run.
Private Sub CommandButton1_Click()
    Call Add_Dynamic_Checkbox
End Sub

Procedure to call in the Command Button:

Sub Add_Dynamic_Checkbox()
    '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  
    1. Now, click F5 to run the macro, click ‘Create_Checkbox’ button to see the result.
    2. You can see the created dynamic check box in the following screen shot.

output:

Dynamic Checkbox

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 ChkBox_Ex1()
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.
Read More …

Here is the one more link to more about how to add check box control on the Worksheet or UserForm using VBA in Excel.
Read More …

Here is the one more link to more about how to remove check box control on the Worksheet or UserForm in Excel.
Read More …

Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Save Up to 85% LIMITED TIME OFFER
Project Management Templates

All-in-One Pack
120+ Project Management Templates

Essential Pack
50+ PM Templates

Excel Pack
50+ Excel PM Templates

PowerPoint Pack
50+ Excel PM Templates

MS Word Pack
25+ Word PM Templates

Ultimate Project
Management Template
Ultimate Resource
Management Template
Project Portfolio
Management Templates
Last Updated: March 2, 2023