Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing PivotField Summary Stats 1

Status
Not open for further replies.

heavnstrl

Technical User
Mar 2, 2003
4
US
I use pivot tables in Excel XP extensively. When creating the pivot table through the wizard, excel 'automatically' determines how to summarize the data (either SUM or COUNT). I frequently use AVERAGE and have yet to find a way to set a default summarization type. Has anyone found a way to override the default or at least a way to batch change pivot fields (excel is requireing me to manually change them one at a time) from xlSum to xlAverage?

Thanks, Carl
 
Hi, heaven,

Don't know of a way to set a default. Maybe some guru out there can come up with it.

However, here's a way to run a macro after the fact, to change every data field to average...
Code:
Sub SetDataFieldsAverage()
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Sum of Age").Function = _
        xlAverage
    For Each PivotTable In ActiveSheet.PivotTables
        For Each DataField In PivotTable.DataFields
            DataField.Function = xlAverage
        Next
    Next
End Sub
Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
Hi Skip,

This worked perfectly. I hadn't realized that I could loop through each datafield with the For Each call. My previous macros were explicitly stating the datafield name which could get pretty tedious.

Thanks!

Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top