GroupedHAlignment Property

Microsoft Office Web Components Object Model

Show All

GroupedHAlignment Property

       

Returns or sets a PivotHAlignmentEnum constant that represents the horizontal alignment of the specified field when it has been grouped. Read/write.

PivotHAlignmentEnum can be one of these PivotHAlignmentEnum constants.
plHAlignAutomatic
plHAlignCenter
plHAlignLeft
plHAlignRight
 

expression.GroupedHAlignment

expression   Required. An expression that returns a PivotField object.

Example

This example groups the Age field of PivotTable1. Starting at age 15, a new group will be created for every five years until age 80. Then, the font, foreground, background, height and alignment of the resulting groups are formatted.

Sub AddGrouping()

    Dim vwView
    Dim ptConstants
    Dim pfGroupedField

    Set ptConstants = PivotTable1.Constants

    ' Set a variable to the active view of the PivotTable.
    Set vwView = PivotTable1.ActiveView
	
    ' Set a variable to the Age field.
    Set pfGroupedField = vwView.FieldSets("Age").Fields("Age")
	
    ' Set the GroupOn property so that the Age field will be
    ' grouped by the GroupInterval setting.
    pfGroupedField.GroupOn = ptConstants.plGroupOnInterval

    ' Create a new grouping for every five years.
    pfGroupedField.GroupInterval = 5

   ' Start the grouping at age 15.
    pfGroupedField.GroupStart = 15

    ' End the grouping at age 80.
    pfGroupedField.GroupEnd = 80
	
    ' Set the font for the field when it is grouped.
    pfGroupedField.GroupedFont.Bold = True

    ' Set the foreground color for the field when it is grouped.
    pfGroupedField.GroupedForeColor = "Black"

    ' Set the Background color for the field when it is grouped.
    pfGroupedField.GroupedBackColor = "Blue"

    ' Set the height for the field when it is grouped.
    pfGroupedField.GroupedHeight = 15

    ' Set the horizontal alignment for the field when it is grouped.
    pfGroupedField.GroupedHAlignment = ptConstants.plHAlignRight
	
End Sub