expression.GroupedForeColor
expression Required. An expression that returns a PivotField object.
Remarks
When you set this property, you can use either a Long value representing a red-green-blue color value or a String value naming a valid HTML color value. For example, to set the object color to red, you could use the hexadecimal value &HFF, the decimal value 255, or the string value "red." In Microsoft Visual Basic, you can use the RGB function to create a red-green-blue color value (red is RGB(255,0,0)
).
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