HorizontalAlignment Property

Microsoft Excel Visual Basic

Show All

HorizontalAlignment Property

       

HorizontalAlignment property as it applies to the Style and TextFrame objects.

Returns or sets the horizontal alignment for the specified object. For all objects, this can be one of the following XlHAlign constants. Read/write XlHAlign.

XlHAlign can be one of these XlHAlign constants.
xlHAlignCenter
xlHAlignCenterAcrossSelection
xlHAlignDistributed
xlHAlignFill
xlHAlignGeneral
xlHAlignJustify
xlHAlignLeft
xlHAlignRight

expression.HorizontalAlignment

expression   Required. An expression that returns one of the above objects.

 

HorizontalAlignment property as it applies to the AxisTitle, CellFormat, ChartTitle, DataLabel, DataLabels, DisplayUnitLabel, and Range objects.

Returns or sets the horizontal alignment for the specified object. Read/write Variant.

expression.HorizontalAlignment

expression   Required. An expression that returns one of the above objects.

 

Remarks

Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

Example

This example left aligns the range A1:A5 on Sheet1.

Worksheets("Sheet1").Range("A1:A5").HorizontalAlignment = xlLeft