04 Subtotal - AndrewMB2/Logic-Architect-for-Excel-VBA GitHub Wiki

Subtotal method

Creates subtotals. Returns True is successful, otherwise false.

Applies to

TableData ArrData RsetData Xdata XShared

Parameters

Name Type Description
GroupBy Variant Name or number of the field to group by (or in ArrData, array of field names/numbers).
SubFunction XlConsolidationFunction enumeration The subtotal function.
Replace Boolean True to replace existing subtotals (TableData only).
PageBreaks Boolean True to add page breaks after each group (TableData only).
SummaryBelowData XlSummaryRow enumeration Places the summary data relative to the subtotal.
TotalList Value, array or Paramarray Fields (name or number) to which the subtotal is to be added.

For TableData, implements the Range.Subtotal method, though simplifies the specification of fields as field names can be used rather than column numbers.

Because Subtotal on worksheets in some cases can be very slow, a simplified form of Subtotal has been implemented in ArrData. SubFunction is ignored, and is always total; SummaryBelowData is ignored and is always below data. Replace is not present, subtotals are always added to the data. PageBreaks is not relevant. However it is possible to group by multiple fields (in which case the GroupBy parameter will be an array). The resulting ArrData object can simply be copied to a TableData object to produce a report with subtotals.