Share via


Range.Group Method

When the Range object represents a single cell in a PivotTable field’s data range, the Group method performs numeric or date-based grouping in that field.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function Group ( _
    Start As Object, _
    End As Object, _
    By As Object, _
    Periods As Object _
) As Object
'Usage
Dim instance As Range
Dim Start As Object
Dim End As Object
Dim By As Object
Dim Periods As Object
Dim returnValue As Object

returnValue = instance.Group(Start, End, _
    By, Periods)
Object Group(
    Object Start,
    Object End,
    Object By,
    Object Periods
)

Parameters

  • Start
    Type: System.Object

    Optional Object. The first value to be grouped. If this argument is omitted or True, the first value in the field is used.

  • End
    Type: System.Object

    Optional Object. The last value to be grouped. If this argument is omitted or True, the last value in the field is used.

  • By
    Type: System.Object

    Optional Object. If the field is numeric, this argument specifies the size of each group. If the field is a date, this argument specifies the number of days in each group if element 4 in the Periods array is True and all the other elements are False. Otherwise, this argument is ignored. If this argument is omitted, Microsoft Excel automatically chooses a default group size.

  • Periods
    Type: System.Object

    Optional Object. An array of Boolean values that specify the period for the group, as shown in the following table.

    If an element in the array is True, a group is created for the corresponding time; if the element is False, no group is created. If the field isn’t a date field, this argument is ignored.

Return Value

Type: System.Object

Remarks

The Range object must be a single cell in the PivotTable field’s data range. If you attempt to apply this method to more than one cell, it will fail but will not display an error message.

See Also

Reference

Range Interface

Range Members

Microsoft.Office.Interop.Excel Namespace