subtotal function

A

arevans

Can anyone help me understand the parameters of the
subtotal function ?

For example, if in my code I want to do something like
this:

Worksheets("SubTotals").Range("D3: E900").Name = "MyRange"

MyRange.Subtotal GroupBy:=2, Function:=xlSum, _
TotalList:=2, Replace:=True, _
PageBreaks:=False, SummaryBelowData:=False

I'm OK with "Function", "Replace", "PageBreaks"
and "SummaryBelowData", but what is GroupBy and TotalList ?
What would the syntax be in this example ?
Thanks for your help.
 
B

Bob Phillips

Repint from the online help

Subtotal Method


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

For information about using the Subtotal worksheet function in Visual Basic,
see Using Worksheet Functions in Visual Basic.

Syntax

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

expression Required. An expression that returns a Range object.

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

Function Required Long. The subtotal function. Can be one of the following
XlConsolidationFunction constants: xlAverage, xlCount, xlCountNums, xlMax,
xlMin, xlProduct, xlStDev, xlStDevP, xlSum, xlVar, or xlVarP.

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

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

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

SummaryBelowData Optional Variant. Can be one of the following
xlSummaryRow constants: xlSummaryAbove or xlSummaryBelow. The default value
is xlSummaryBelow.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Subtotal function 2
Subtotal by VBA 5
Subtotal Formatting 2
Subtotal for same range of multiple worksheets 5
Subtotals 2
Excel Subtotals 2
subtotal question 1
Issue with nested data subtotals 3

Top