I have a ton of data fields that contain some blank cells, which cause the field to use "Count" as the default. I need it to Sum and resetting each field is taking forever. Is there a way to change the default to "Sum" or change the setting to more than one field at a time. (When I try to change multiple field settings, only the first one is changed.)
Thanks,
droach
Assuming all the fields already exist in the Data Field section of your PT
alter that above in red as appropriateCode:Public Sub SET_PTFIELDS_TO_SUM() Dim PT As PivotTable, PTField As PivotField Set PT = ActiveSheet.PivotTables(1) For Each PTField In PT.DataFields PTField.Function = xlSum Next PTField Set PT = Nothing End Sub
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Thanks for the reply. I'm a moderate Excel user...
Is what you posted the code for a macro I can run? I tried to run it in the VB editor but is keeps saying that I need an "object". Any ideas?
Thanks in advance for your help.
droach
On what sheet is the Pivot Table resident ? What is the Pivot Table called ?
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
The sheet is called "Pivot" and the work book is called "Buyer_Recap_DR1
". I don't think I named the actual Pivot Table. Is there a default? Where would I find the name?
Thanks,
droach
To ascertain the name of the Pivot Table, right click on it and select Table Options the first box should detail the name.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
download this addin. It will allow you to change the entire pivot table to count, sum, etc in just a few clicks. It is on the contextures excel site.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks