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

Alignment property of checkbox control is used to specify the position of a checkbox control in Excel VBA. It sets an integer value. The possible values are 0(Left side of a control) or 1(Right side of a control).

Alignment Property Excel CheckBox Object_1

Checkbox_Alignment_Property – Syntax

Please find the below syntax of Checkbox control Alignment Property in Excel VBA.

CheckboxName.Alignment=0 (fmAlignmentLeft )

Or

CheckboxName.Alignment=1 (fmAlignmentRight )

Where CheckboxName represents the Checkbox object. In the above syntax we are using ‘Alignment’ property of Checkbox object to set the alignment of Checkbox control.

Checkbox_Alignment_Property – Explanation & Example

Here is the example for Checkbox control Alignment_Property. It will take you through how to set alignment property of Checkbox control property using Excel VBA. Here you can find or see how we are using ‘Alignment’ property of Checkbox manually or using code.

Checkbox_Alignment_Property: Change Manually

Please find the following details how we are changing manually ‘Alignment’ property of Checkbox property.

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

Excel VBA UserForm CheckBox

    1. Drag a Checkbox on the Userform from the Toolbox.

AxtiveX Checkbox Control1

    1. Right click on the List box. Click on properties from the available list.

CheckBox Properties1

    1. Now you can find the properties window of Checkbox on the screen. Please find the screenshot for the same.

CheckBox Properties

    1. On the left side find ‘Alignment’ property from the available List Box properties.
    2. On the right side you can see the two available options. i.e.

I. 0 – fmAlignmentLeft
II. 1 – fmAlignmentRight

    1. You can choose any one from the available options. For example, I have choosen ‘0 – fmAlignmentLeft’. This means Checkbox alignment is towards left. You can see same in the screen shot for your understand.

Alignment Property of CheckBox Control2

    1. You can choose ‘1 – fmAlignmentRight’ from the available options. This means Checkbox alignment is towards right side. You can see same in the screen shot for your understand.

Alignment Property of CheckBox Control3

Checkbox_Alignment_Property: Change Using Code

Please find the following details how we are changing Alignment of Checkbox property with using Excel VBA code.

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

Excel VBA UserForm CheckBox

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

AxtiveX Checkbox Control1

      1. Double Click on the UserForm, and select the Userform event as shown in the below screen shot.

List Box Excel ActiveX Control _Im1

      1. Now can see the following code in the module.
Private Sub UserForm_Initialize()

End Sub
      1. Now, add the following example code1 or code2 or code3 to the in between above event procedure.

Example Code 1:

Here is the example and output when we set column count property to ‘0’. This means it will display all columns in a Checkbox.

'Alignment Property of Checkbox Control
Private Sub UserForm_Initialize()
    'The below statement specifies the checkbox position
    CheckBox1.Alignment = fmAlignmentLeft
End Sub 

Or

Private Sub UserForm_Initialize()
    'The below statement specifies the checkbox position
    CheckBox1.Alignment = 0
End Sub 
      1. Now, Press ‘F5’ to see the following Output.

Output: If Alignment =0 or fmAlignmentLeft
Please find the below output when we set Alignment property value is 0. It is shown in the following Screen Shot.

Alignment Property of CheckBox Control1

Example Code 2:

Here is the example and output when we set column count property to ‘1’. This means it will display all columns in a Checkbox.

'Alignment Property of Checkbox Control
Private Sub UserForm_Initialize()
    'The below statement specifies the checkbox position
    CheckBox1.Alignment = fmAlignmentRight
End Sub 

Or

Private Sub UserForm_Initialize()
    'The below statement specifies the checkbox position
    CheckBox1.Alignment = 1
End Sub 
      1. Now, Press ‘F5’ to see the following Output.

Output: If Alignment =1 or fmAlignmentRight
Please find the below output when we set Alignment property value is 1. It is shown in the following Screen Shot.

Alignment Property of CheckBox Control

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

Leave A Comment