+ Reply to Thread
Results 1 to 19 of 19

Pivot Table - Remove "sum of" in data field

Hybrid View

  1. #1
    Registered User
    Join Date
    05-26-2006
    Posts
    5

    Pivot Table - Remove "sum of" in data field

    Is there a way to modify Pivot Table so that "Sum of, Count of", etc is not shown.
    For example, have Table (& Pivot Chart) show "West Region" instead of "Sum of West Region"

    Thanks

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    If you right-click on the pivot table and select "Field Settings", you can change the text that is displayed by amending the "Name" field.

    Hope this helps!

    Best regards

    Richard

  3. #3
    Registered User
    Join Date
    05-26-2006
    Posts
    5
    That worked. Thanks very much

  4. #4
    Registered User
    Join Date
    03-30-2011
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Pivot Table - Remove "sum of" in data field

    the following code will achieve what you want.
    Sub ChangePTName() 
    Dim pt As PivotTable, pf As PivotField, ws As Worksheet, i As Long 
    Application.ScreenUpdating = False 
    Set ws = ActiveSheet 
    For i = 1 To ws.PivotTables.Count 
    Set pt = ws.PivotTables(i) 
    pt.ManualUpdate = True 
    For Each pf In pt.DataFields 
    If pf.Function = xlSum Then 
    If Left(pf.Caption, 6) = "Sum of" Then 
    pf.Caption = Right(pf.Caption, Len(pf.Caption) - 6) 
    End If 
    End If 
    Next 
    pt.ManualUpdate = False 
    Next i 
    Application.ScreenUpdating = True 
    End Sub
    Copy the Code above
    Alt+F11 to invoke the VB Editor
    Insert>Module
    Paste code into white pane that appears
    Alt+F11 to return to Excel

    To use
    Select sheet containing the PT's
    Alt+F8 to bring up Macros
    Highlight ChangePTName
    Run

  5. #5
    Registered User
    Join Date
    05-14-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Pivot Table - Remove "sum of" in data field

    This is awesome. Thank you!


    Quote Originally Posted by talhawahab View Post
    the following code will achieve what you want.
    Sub ChangePTName() 
    Dim pt As PivotTable, pf As PivotField, ws As Worksheet, i As Long 
    Application.ScreenUpdating = False 
    Set ws = ActiveSheet 
    For i = 1 To ws.PivotTables.Count 
    Set pt = ws.PivotTables(i) 
    pt.ManualUpdate = True 
    For Each pf In pt.DataFields 
    If pf.Function = xlSum Then 
    If Left(pf.Caption, 6) = "Sum of" Then 
    pf.Caption = Right(pf.Caption, Len(pf.Caption) - 6) 
    End If 
    End If 
    Next 
    pt.ManualUpdate = False 
    Next i 
    Application.ScreenUpdating = True 
    End Sub
    Copy the Code above
    Alt+F11 to invoke the VB Editor
    Insert>Module
    Paste code into white pane that appears
    Alt+F11 to return to Excel

    To use
    Select sheet containing the PT's
    Alt+F8 to bring up Macros
    Highlight ChangePTName
    Run

  6. #6
    Registered User
    Join Date
    06-11-2013
    Location
    Richardson, TX
    MS-Off Ver
    Excel 2010
    Posts
    1

    Cool Re: Pivot Table - Remove "sum of" in data field

    Quote Originally Posted by pumbaa View Post
    This is awesome. Thank you!
    + 1,000! Thanks


    You will also have to save your file as a 'macro enabled workbook'.
    Last edited by TexExp; 06-11-2013 at 10:27 AM.

  7. #7
    Registered User
    Join Date
    04-12-2016
    Location
    Taizhou, Jiangsu, China
    MS-Off Ver
    2016
    Posts
    1

    Re: Pivot Table - Remove "sum of" in data field

    Quote Originally Posted by TexExp View Post
    + 1,000! Thanks


    You will also have to save your file as a 'macro enabled workbook'.
    How can this thing be a default for all Excel Workbook?

  8. #8
    Registered User
    Join Date
    04-11-2014
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    28

    Question PowerPivot - Remove "sum of" in data field

    Quote Originally Posted by pumbaa View Post
    This is awesome. Thank you!
    This works great with a regular Pivot Table but doesn't work with pivot table created using PowerPivot. Any solution?

    Thank you!


    Joji

  9. #9
    Registered User
    Join Date
    03-20-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Pivot Table - Remove "sum of" in data field

    FANTASTIC! Thanks Tal!

  10. #10
    Registered User
    Join Date
    06-29-2011
    Location
    Bangkok
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Pivot Table - Remove "sum of" in data field

    Thanks so much!

  11. #11
    Registered User
    Join Date
    09-26-2014
    Location
    Wales
    MS-Off Ver
    2010
    Posts
    1

    Re: Pivot Table - Remove "sum of" in data field

    This has worked perfectly for me and saved me a lot of frustration. Appreciate the simple instructions as well.

    Many Thanks

  12. #12
    Registered User
    Join Date
    12-08-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Pivot Table - Remove "sum of" in data field

    Just used this - really big help - thank you

  13. #13
    Registered User
    Join Date
    02-26-2014
    Location
    Amsterdam
    MS-Off Ver
    Excel 2011 MAC
    Posts
    3

    Re: Pivot Table - Remove "sum of" in data field

    Is there a version/language independent workaround? For example in dutch "sum of" becomes "Som van". Since i want my macro not to be depended on the language excel is installed, the code above wont work.

    This part wont work:
    If Left(pf.Caption, 6) = "Sum of" Then

  14. #14
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Pivot Table - Remove "sum of" in data field

    It is not possible to rename field to same as source field but you may try:
    Sub ChangePTName()
       Dim pt                          As PivotTable
       Dim pf                          As PivotField
       Dim ws                          As Worksheet
       Dim i                           As Long
    
       Application.ScreenUpdating = False
       Set ws = ActiveSheet
       For Each pt In ws.PivotTables
          pt.ManualUpdate = True
          For Each pf In pt.DataFields
             If pf.Function = xlSum Then
                pf.Caption = pf.SourceName & " "
             End If
          Next
          pt.ManualUpdate = False
       Next pt
       Application.ScreenUpdating = True
    End Sub
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  15. #15
    Registered User
    Join Date
    02-26-2014
    Location
    Amsterdam
    MS-Off Ver
    Excel 2011 MAC
    Posts
    3

    Re: Pivot Table - Remove "sum of" in data field

    Thanks that did the trick!

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Pivot Table - Remove "sum of" in data field

    Joji,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  17. #17
    Registered User
    Join Date
    11-17-2014
    Location
    Melbourne, Australia
    MS-Off Ver
    MS Office 2007
    Posts
    1

    Re: Pivot Table - Remove "sum of" in data field

    Thank you so much, great help!

  18. #18
    Registered User
    Join Date
    12-12-2014
    Location
    NL
    MS-Off Ver
    2010/2013
    Posts
    1

    Re: Pivot Table - Remove "sum of" in data field

    works, thanks!

  19. #19
    Registered User
    Join Date
    08-31-2011
    Location
    Stamford, CT
    MS-Off Ver
    Excel 2013
    Posts
    30

    Re: Pivot Table - Remove "sum of" in data field

    Another quick workaround is to replace "Sum of" with a blank space.. or delete it out and put a space after the variable name. If you have a lot of variables you can just Find/Replace "Sum of" with nothing and that will give you the same result.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1