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


Related pages


macros for excel 2007excel auto row heightdelete macro excelexcel replace formulaexcel vba beginner tutorialfunction in vba excelvba variable typesshortcut key insert row excelexcel vlookup formulaslearn to write macros in excelamazing excel templatesvba tutorialvba range sortproject tracking spreadsheet templateexcel current worksheetsas programming video tutorialshow can i unhide columns in exceliserror excelactivex comboboxddl and dml commands in sql servervba closecommonly asked interview questions with answers for freshersascending and descending order in excelaccess 2013 activex controlsconvert excel csvplanning calendar template excelrange.autofilterexcel tabs in alphabetical orderworkbook in excel definitionexcel auto column widthworkbooks.close vbavba coding for dummiesexcel remove blanksheet tab excelif iserror formulacell value excel vbacell color excel vbams access vba run macrocapacity planning spreadsheet exceldim string vbaexcel copy worksheetchart creation in excelvlookup in excel 2007sumif excel 2007construction budget template excelhyperlink macro excelms powerpoint questions and answersvba column widthnested conditional statementsvba copy worksheet to new workbookreverse cell order excelhow to change column name in excelcreate excel macrolookups excelexcel combine multiple worksheets into onevariables in excel vbavba color chartvba save excel3d cluster chart excelaptitude test on excelhow to protect a column in excel 2007vlook up examplesas do while loop examplehow to expand rows in excelexcel vba advanced tutorialvba index colorexcel insert chart titleremove blank cells in excel formulacapacity model template excelexcel vba print commandproject timelines exceldelete a row in excel vbaautomation testing interview questions and answers pdfconcatenate formulamoving sheets in excelsort worksheets alphabeticallyname range in excel 2007shortcut key to remove hyperlink in excelcool excel graphs