Pivot table "Sum of" or "Count of"

S

Scott

I have created a macro to create several pivot tables. Some show "Sum of XXX"
and some "Count of XXX". I actually want all to be "Sum of XXX". So how to
change the macro to show "Sum of" when the pivot table gives "Count of". Here
are codes for one of the tables:
With pt1
.PivotFields("REGION").Orientation = xlPageField
.PivotFields("DIVISION").Orientation = xlColumnField
.PivotFields("YEAR").Orientation = xlRowField
.PivotFields("SALES").Orientation = xlDataField
End With

Thanks,
Scott
 
D

Debra Dalgleish

You can add a bit of code to change all the data fields to SUM:

'=================
Dim pf As PivotField
For Each pf In pt1.DataFields
pf.Function = xlSum
Next pf
'===============
 

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

Top