Share via


DetailHAlignment Property

PivotHAlignmentEnum

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

Applies to | PivotField Object

See Also | HAlignment Property

expression.DetailHAlignment

*expression   * Required. An expression that returns a PivotField object.

Example

This example adds inserts fields into PivotTable1, add a total, and then formats the field in the detail area of the PivotTable list.

Sub Layout_PivotTable1()
    Dim vwView
    Dim ptConstants
    Dim totOrderCount
 
    Set ptConstants = PivotTable1.Constants
    Set vwView = PivotTable1.ActiveView
 
    ' Add the ShipCountry field to the row axis.
    vwView.RowAxis.InsertFieldSet
    vwView.FieldSets("ShipCountry")
 
    ' Add the OrderId field to the data axis.
    vwView.DataAxis.InsertFieldSet vwView.FieldSets("OrderID")
 
    ' Add the ShipVia field to the filter axis.
    vwView.FilterAxis.InsertFieldSet
    vwView.FieldSets("ShipVia")
    
    ' Create a total named "Order Count" that counts
    ' the OrderID field. 
    Set totOrderCount = vwView.AddTotal("Order Count",
    vwView.FieldSets("OrderId").Fields("OrderId"), _
    ptConstants.plFunctionCount)
    
    ' Add the Order Count total to the data axis.
    vwView.DataAxis.InsertTotal totOrderCount
    
    ' Set the horizontal alignment of the OrderID field.
    vwView.FieldSets("OrderId").Fields("OrderId").DetailHAlignment = plHAlignCenter
       
    ' Set the foreground color of the OrderId field.
    vwView.FieldSets("OrderId").Fields("OrderId").DetailForeColor = RGB(100, 100, 200)
 
End Sub