Checkbox Alignment Property

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).

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates


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.
  3. Excel VBA UserForm CheckBox

  4. Drag a Checkbox on the Userform from the Toolbox.
  5. AxtiveX Checkbox Control1

  6. Right click on the List box. Click on properties from the available list.
  7. CheckBox Properties1

  8. Now you can find the properties window of Checkbox on the screen. Please find the screenshot for the same.
  9. CheckBox Properties

  10. On the left side find ‘Alignment’ property from the available List Box properties.
  11. On the right side you can see the two available options. i.e.
  12. I. 0 – fmAlignmentLeft
    II. 1 – fmAlignmentRight

  13. 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.
  14. Alignment Property of CheckBox Control2

  15. 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.
  16. 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.
    3. Excel VBA UserForm CheckBox

    4. Drag a Checkbox on the Userform from the Toolbox. Please find the screenshot for the same.
    5. AxtiveX Checkbox Control1

    6. Double Click on the UserForm, and select the Userform event as shown in the below screen shot.
    7. List Box Excel ActiveX Control _Im1

    8. Now can see the following code in the module.
    9. Private Sub UserForm_Initialize()
      End Sub
      
    10. Now, add the following example code1 or code2 or code3 to the in between above event procedure.
    11. 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 
      
    12. Now, Press ‘F5’ to see the following Output.
    13. 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 
      
    14. Now, Press ‘F5’ to see the following Output.
    15. 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

LIMITED TIME OFFER

Leave A Comment