remove subtotals from pivot tables

G

Guest

I am trying to generate a pivot table from a set of data but I want to be
able to run this at any time so the obvious solution would be a macro. I
recorded the macro and checked the radio button for subtotals = none which
brought up the following code:
ActiveSheet.PivotTables("PivotTable5").PivotFields("Charge Week").Subtotals
= Array(False, False, False, False, False, False, False, False, False, False,
False, False)

Is there a better way of doing this other than an array such as Subtotals=
none or something like that as I assume that the array will alter depending
on certain criteria?
 
T

Tom Ogilvy

Why not check out the subtotals property in help:

Returns or sets subtotals displayed with the specified field. Valid only for
nondata fields. Read/write Variant.

expression.Subtotals(Index)

expression Required. An expression that returns a PivotField object.

Index Optional Variant. A subtotal index, as shown in the following
table. If this argument is omitted, the Subtotals method returns an array
that contains a Boolean value for each subtotal.

Index Meaning
1 Automatic
2 Sum
3 Count
4 Average
5 Max
6 Min
7 Product
8 Count Nums
9 StdDev
10 StdDevp
11 Var
12 Varp


If an index is True, the field shows that subtotal. If index 1 (Automatic)
is True, all other values are set to False.

---------------------------------------------------



So setting everything to false is the way to indicate none.



So I wouldn't see an easier way to do it.
 

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


Top