Creates subtotals for the range (or the current region, if the range is a single cell).
Worksheets("Sheet1").Activate Selection.Subtotal GroupBy:=1, Function:=xlSum, _ TotalList:=Array(2, 3)
The following arguments are required:
GroupBy (Long) - The field to group by, as a one-based integer offset. For more information, see the example.
Function (XlConsolidationFunction) - The subtotal function.
Here you can find possible values for XlConsolidationFunction.
TotalList - An array of 1-based field offsets, indicating the fields to which the subtotals are added. For more information, see the example
The following arguments are optional
Replace (Boolean) - True to replace existing subtotals. The default value is True.
PageBreaks (Boolean) - True to add page breaks after each group. The default value is False.
SummaryBelowData (XlSummaryRow) - Places the summary data relative to the subtotal.Possible Values are xlSummaryAbove - The summary row will be positioned above the detail rows in the outline, xlSummaryBelow - The summary row will be positioned below the detail rows in the outline.