+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    12-02-2009
    Location
    Dickson, TN USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Changing default for field settings in pivot tables

    Every time I create a pivot table, the fields are automatically set to Sum. Is there a way to change the default so I can get them to automatically be set to Average as I build the table. I have a ton of fields to add and do not want to have to change the field settings on every one.

  2. #2
    Forum Moderator romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Alibi
    MS-Off Ver
    All
    Posts
    8,262

    Re: Changing default for field settings in pivot tables

    Unfortunately not, but you can use a macro to apply that afterwards:
    Code:
    Public Sub SetDataFieldsToAverage()
    '
    ' Sets all data fields to average
       Dim ptf As PivotField
       With Selection.PivotTable
          .ManualUpdate = True
          For Each ptf In .DataFields
             With ptf
                .Function = xlAverage
    '            .NumberFormat = "#,##0"
             End With
          Next ptf
          .ManualUpdate = False
       End With
    End Sub
    So long, and thanks for all the fish.

  3. #3
    Registered User
    Join Date
    12-02-2009
    Location
    Dickson, TN USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Changing default for field settings in pivot tables

    Thanks RomperStomper,

    I was afraid that was going to be the answer. By the way, do you have similar code that sets the defaults to not display sub-totals?

    Thanks Again,
    Jim

  4. #4
    Forum Moderator romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Alibi
    MS-Off Ver
    All
    Posts
    8,262

    Re: Changing default for field settings in pivot tables

    Yep.
    Code:
    Sub RemovePivotSubtotals()
       Dim PT As PivotTable
       Dim pf As PivotField
       On Error Resume Next
       Set PT = ActiveCell.PivotTable
       If PT Is Nothing Then Exit Sub
       PT.ManualUpdate = True
       For Each pf In PT.RowFields
          pf.Subtotals(1) = True
          pf.Subtotals(1) = False
       Next pf
          For Each pf In PT.ColumnFields
          pf.Subtotals(1) = True
          pf.Subtotals(1) = False
       Next pf
       PT.ManualUpdate = False
    End Sub
    So long, and thanks for all the fish.

  5. #5
    Registered User
    Join Date
    12-02-2009
    Location
    Dickson, TN USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Changing default for field settings in pivot tables

    Wow, thanks. Should have asked this question a long time ago....

    Really appreciate your help!

    Jim

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0