Note: The other languages of the website are Google-translated. Back to English

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?

doc-change-field-setting-1

Change the field settings in pivot table manually one by one

Change multiple field settings in pivot table with VBA code

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

arrow blue right bubble 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:

doc-change-field-setting-1

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:

doc-change-field-setting-1

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

doc-change-field-setting-1

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.

doc-change-field-setting-1


arrow blue right bubble 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:

doc-change-field-setting-1
-1
doc-change-field-setting-6

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.


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

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!
officetab bottom
Comments (28)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi, The tips and VB macros is really helpful. Thanks
This comment was minimized by the moderator on the site
Good Day, Wonderful. It really helps a lot. Your Pivot tips are so wonderful I am looking for years and i got real help How can we add function for decimals also. Thanks a lot
This comment was minimized by the moderator on the site
Thank you for the solution. For reason I get an error on the .NumberFormat = "#,##0". I am changing from Sum to Average which works fine but I also want to change the NumberFormat to Number with 1 decimal. Thanks
This comment was minimized by the moderator on the site
Hi, Thank you for the very good solution! Is it possible to make it automatic? So whenever I add a new Field to the values this macro should run. thank you in advance, Jani
This comment was minimized by the moderator on the site
This is so useful. This problem has bothered me for years and now its solved.
This comment was minimized by the moderator on the site
Thanks for this! Is there any way to use StdDev instead of Sum? I was able to change your code for Average & Count, but I can't get StdDev to work. Thanks!
This comment was minimized by the moderator on the site
Hi Kelsey - I'm wondering if you ever received an answer to this? I am trying to do the same thing. Thanks!
This comment was minimized by the moderator on the site
Kelsey- did you get an answer for this or figure this out? I tried to edit the code but have not been able to figure it out yet. I was not sure if there was a way to quickly change it for the different summation options. Thanks!
This comment was minimized by the moderator on the site
Kelsey, I just created a macro and changed one manually and then checked the macro code in VBA. To get StdDev to Work use StDev. Code becomes the following:


Public Sub SetDataFieldsToStDev()
'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 = xlStDev
.NumberFormat = "#,##0"
End With
Next
.ManualUpdate = False
End With
End Sub
This comment was minimized by the moderator on the site
hi this is very useful thanks for that. im just wondering is it possible to set just a few or specific columns's value field settings? i mean for example i have values in the first 20 columns and i want to see the data in SUM but from 21th columns comes another type of data (for example distribution) and from that column I would like to see the data in MAX value. so is it possible somehow find for example the name of the header and if "distribution" is there change every "distribution" columns into MAX value. does it make sense? cheers Zoltan
This comment was minimized by the moderator on the site
did you ever get a reply to this? I have the same question
This comment was minimized by the moderator on the site
Just what I was looking for !! Right after the .NumberFormat line, I added a rename for the column heading in the pivot, so I did not have "Sum of" in all of them. .Caption = " " & xPF.SourceName Thanks again !!
This comment was minimized by the moderator on the site
Change Multiple Field Settings In Pivot Table With VBA Code


Amazing! Thank you so much. So helpful with my work.
This comment was minimized by the moderator on the site
This is incredible. I've been frustrated with this problem for years, with some docs with 50+ fields. This is such a time saver!
This comment was minimized by the moderator on the site
Amazing - I am no hot shot with VBA and feel like a champion - this has been driving me crazy for a long time! Thank you
This comment was minimized by the moderator on the site
SuperB... I've been frustrated with this problem
This comment was minimized by the moderator on the site
Brilliant!!!! Thank you so much this was amazing!!!
This comment was minimized by the moderator on the site
How about Average, Stddev, Max and Min for each field successively?
This comment was minimized by the moderator on the site
I've used the VBA solution with great success in the past, but it doesn't work with the data model. Do you know if there is a solution for that?
This comment was minimized by the moderator on the site
Thank you. The code worked beautifully and saved me a lot of wasted time and energy!
This comment was minimized by the moderator on the site
Thank you so much for the VBA code, I LOVE it!
This comment was minimized by the moderator on the site
Thank you so much!!! That is sooo helpful and brilliant! Saved me soooo much time
This comment was minimized by the moderator on the site
I got this error, "Unable to get the Pivot Table property of the Range class". Do you know how I can fix this?
This comment was minimized by the moderator on the site
I got the error" Unable to get the PivotTable property of the range class". Do you know hoe can I fix this?
This comment was minimized by the moderator on the site
Thank you so much, this VBA code works amazing. 
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations