Skip to main content

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.


expression.Group (Start, End, By, Periods)

expression A variable that represents a Range object.


Name Required/Optional Data type Description
Start Optional Variant The first value to be grouped. If this argument is omitted or True, the first value in the field is used.
End Optional Variant The last value to be grouped. If this argument is omitted or True, the last value in the field is used.
By Optional Variant 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 Optional Variant An array of Boolean values that specify the period for the group, described in the Remarks section. 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



The Boolean array for the Periods parameter contains the following elements:

Array element Period
1 Seconds
2 Minutes
3 Hours
4 Days
5 Months
6 Quarters
7 Years

Because a group of shapes is treated as a single shape, grouping and ungrouping shapes changes the number of items in the Shapes collection and changes the index numbers of items that come after the affected items in the collection.

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 (without displaying an error message).

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>