Export (0) Print
Expand All

Range.Subtotal Method

Office 2007
Creates subtotals for the range (or the current region, if the range is a single cell).

Syntax

expression.Subtotal(GroupBy, Function, TotalList, Replace, PageBreaks, SummaryBelowData)

expression   A variable that represents a Range object.

Parameters

NameRequired/OptionalData TypeDescription
GroupByRequiredLongThe field to group by, as a one-based integer offset. For more information, see the example.
FunctionRequiredXlConsolidationFunction. The subtotal function.
TotalListRequiredVariantAn array of 1-based field offsets, indicating the fields to which the subtotals are added. For more information, see the example.
ReplaceOptionalVariantTrue to replace existing subtotals. The default value is True.
PageBreaksOptionalVariantTrue to add page breaks after each group. The default value is False.
SummaryBelowDataOptionalXlSummaryRow. Places the summary data relative to the subtotal.

Return Value
Variant

Example

This example creates subtotals for the selection on Sheet1. The subtotals are sums grouped by each change in field one, with the subtotals added to fields two and three.

Visual Basic for Applications
Worksheets("Sheet1").Activate
Selection.Subtotal GroupBy:=1, Function:=xlSum, _
    TotalList:=Array(2, 3)



Community Additions

ADD
Show:
© 2014 Microsoft