VerticalAlignment Property

Microsoft Office Web Components Object Model

Show All

VerticalAlignment Property

       

Returns or sets the vertical alignment of the specified object. Can be an XlVAlign constant. Read/write Variant.

XlVAlign can be one of these XlVAlign constants.
xlVAlignCenter
xlVAlignLeft
xlVAlignRight
 

expression.VerticalAlignment

expression   Required. An expression that returns a Range object.

Example

This example top-aligns the contents of cells C7:G10 on Sheet1 in Spreadsheet1.


Sub SetAlignment()
   Dim rngAlign
   Dim ssConstants

   Set ssConstants = Spreadsheet1.Constants

   Set rngAlign = Spreadsheet1.Worksheets("Sheet1").Range("C7:G10")

   ' Center the contents of the range horizontally.
   rngAlign.HorizontalAlignment = ssConstants.xlHAlignCenter

   ' Vertically align the contents of the range at the top of the cells.
   rngAlign.VerticalAlignment = ssConstants.xlVAlignTop
End Sub