Skip to content

Instantly share code, notes, and snippets.

@ateneva
Last active April 21, 2018 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ateneva/cb7af2fd9bbb4ba7b8278357d90d0fb1 to your computer and use it in GitHub Desktop.
Save ateneva/cb7af2fd9bbb4ba7b8278357d90d0fb1 to your computer and use it in GitHub Desktop.
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