Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Chnage Pivot Field default name
Sub ChangeDefaultPFName()
Dim Wks As Worksheet
Dim PT As PivotTable
Dim PF As PivotField
Dim Title As String
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'written by Angelina Teneva, September 2016
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Each Wks In ActiveWorkbook.Worksheets
For Each PT In Wks.PivotTables
On Error Resume Next
For Each PF In PT.DataFields
Title = PF.name
'comment out the line(s) that you do not need
PF.name = Mid(Title, 8, Len(Title) - 7) & " " 'removes the "sum of", "max of", "min of"
PF.name = Mid(Title, 10, Len(Title) - 9) & " " 'removes the "count of"
PF.name = Mid(Title, 12, Len(Title) - 11) & " " 'removes the "average of", "product of"
Next PF
Next PT
Next Wks
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.