View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default remove subtotals from pivot tables

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.

--

Regards,

Tom Ogilvy



"ChristinaC" wrote in message
...
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?