How to change multiple field settings in pivot table?
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?
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:
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:
3. And then click OK to close this dialog, and you can see your Count function has been changed to Sum function, see screenshot:
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.
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:
![]() |
![]() |
![]() |
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
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!











