Range.Subtotal Method

Definition

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

public object Subtotal (int GroupBy, Microsoft.Office.Interop.Excel.XlConsolidationFunction Function, object TotalList, object Replace, object PageBreaks, Microsoft.Office.Interop.Excel.XlSummaryRow SummaryBelowData = Microsoft.Office.Interop.Excel.XlSummaryRow.xlSummaryBelow);
Public Function Subtotal (GroupBy As Integer, Function As XlConsolidationFunction, TotalList As Object, Optional Replace As Object, Optional PageBreaks As Object, Optional SummaryBelowData As XlSummaryRow = Microsoft.Office.Interop.Excel.XlSummaryRow.xlSummaryBelow) As Object

Parameters

GroupBy
Int32

Required Integer. The field to group by, as a one-based integer offset. For more information, see the example.

Function
XlConsolidationFunction

Required XlConsolidationFunction. The subtotal function. Can be one of the following XlConsolidationFunction constants:xlAveragexlCountxlCountNumsxlMaxxlMinxlProductxlStDevxlStDevPxlSumxlUnknownxlVarxlVarP

TotalList
Object

Required Object. An array of 1-based field offsets, indicating the fields to which the subtotals are added. For more information, see the example.

Replace
Object

Optional Object. True to replace existing subtotals. The default value is False.

PageBreaks
Object

Optional Object. True to add page breaks after each group. The default value is False.

SummaryBelowData
XlSummaryRow

Optional XlSummaryRow. Places the summary data relative to the subtotal. Can be one of the following XlSummaryRow constants:xlSummaryAbovexlSummaryBelowdefault

Returns

Applies to