Share via


AddCustomGroupMember Method

Adds a member to a custom group field. Returns a PivotMember object.

expression.AddCustomGroupMember(Parent, varChildMembers, bstrCaption)

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

Parent   Required Variant. Name, unique name, reference to the parent member for the new member(s).

varChildMembers   Required Variant. Array of member names, unique names, or member references to add to the new custom group member.

bstrCaption   Optional String. The caption to display for the new member.

Remarks

Use this method to populate a field created using the AddCustomGroupField method.

Example

This example adds a custom group field to the Time field set, and then adds two members to the field.

Sub CreateCustomGroup()

   Dim fsTime
   Dim fsHalfYear

   ' Set a variable to the Time field set.
   Set fsTime = PivotTable1.ActiveView.FieldSets("Time")

   ' Add a custom group field named "Group1" to the Time field set.
   Set fsHalfYear = fsTime.AddCustomGroupField("Group1", "Group1", _
                    "Quarter")
    
   ' Add a member to the custom field set. This member includes all "Q1"
   ' and "Q2" members under 1997.
   fsHalfYear.AddCustomGroupMember fsTime.Member.Childmembers("1997").Name, _
                                   Array("Q1","Q2"), "1stHalf"

   ' Add a member to the custom field set. This member includes all "Q3"
   ' and "Q4" under 1997.
   fsHalfYear.AddCustomGroupMember fsTime.Member.ChildMembers("1997").Name, _
                                   Array("Q3","Q4"), "2ndHalf"    

End Sub

Applies to | PivotField Object

See Also | AddCustomGroupField Method | DeleteCustomGroupMember Method | PivotMember Object