Skip to main content

How to change multiple field settings in pivot table?

Author Xiaoyang Last modified

When you create a pivot table in a worksheet, after dragging the fields to the Values list in the PivotTable Field List, you may get all the same Count function as following screenshot shown. But now, you want the Sum of function to replace the Count of function at once, how could you change the calculation of multiple pivot table fields at once in Excel?

a screenshot showing the original PivotTable

Change the field settings in pivot table manually one by one

Change multiple field settings in pivot table with VBA code


Change the field settings in pivot table manually one by one

In Excel, you can change the calculation of the field settings by changing the function one by one in the Value Field Settings dialog, please do as this:

1. Select a field in the Values area for which you want to change the summary function in the pivot table, and right click to choose Value Field Settings, see screenshot:

a screenshot of opening the Value Field Settings dialog box

2. Then in the Value Field Settings dialog box, select one type of calculate which you want to use under the Summarize Value By tab, see screenshot:

a screenshot of selecting one type of calculation

3. And then click OK to close this dialog, and you can see your Count function has been changed to Sum function, see screenshot:

a screenshot showing the changes for one field

4. Repeat the above steps to change other fields’ calculation settings one by one.

Note: You can also change the field settings by right click one field cell and choose Summarize Values by and select one calculation you need from context menus.

a screenshot of changing the field settings by right clicking menu


Change multiple field settings in pivot table with VBA code

The above method will be time consuming and tedious if there are lots of field calculations needed to be changed, here, I can introduce you a code to change multiple filed settings at the same time.

1. Click any cell in your pivot table.

2. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

3. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Change multiple field settings in pivot table

Public Sub SetDataFieldsToSum()
'Update 20141127
Dim xPF As PivotField
Dim WorkRng As Range
Set WorkRng = Application.Selection
With WorkRng.PivotTable
   .ManualUpdate = True
   For Each xPF In .DataFields
      With xPF
         .Function = xlSum
         .NumberFormat = "#,##0"
      End With
   Next
   .ManualUpdate = False
End With
End Sub

4. Then press F5 key to execute this code, and all the field settings in your selected pivot table have been converted to your need calculation at once, see screenshots:

a screenshot showing the orginal PivotTable
a screenshot of an arrow
a screenshot showing the PivotTable after changing the field settings

Note: In the above code, you can change the Sum function to any other calculations, such as Average, Max, Min as you want. You just need to change the Sum in these scripts: Public Sub SetDataFieldsToSum() and .Function = xlSum to other functions.


Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!