9

When using PivotTables in Excel, it's often useful to overtype certain PivotTable labels with new names.

If you have a long list of items you've relabelled, it can be easy to lose track of what the original labels were. The only method I've found to restore the original labels is to go into the source data, dig all the original labels out, and change the PivotTable label back one-at-a-time.

I have over 50 renamed labels, this is tedious.

Is there any way to clear all renamed PivotTable labels for a given field, in one fell swoop?

Edit: I'm using Excel 2010, but interested in any methods available in later versions as well.

fixer1234
  • 28,064
Andi Mohr
  • 4,315

6 Answers6

12
  1. Rename the column header/name in the source
  2. Refresh the pivot. This will drop all forced labels and drop field from the pivot.
  3. Rename the column name back to what it was
  4. Refresh pivot again
  5. Add the field back into your pivot.
Madball73
  • 2,590
3

This macro will remove all captions from the row labels and column labels in all pivottables in a workbook. This will NOT work with PowerPivot Tables.

Sub FixPivotItemCaptions()
Dim pi As PivotItem
Dim pt As PivotTable
Dim wb As Workbook
Dim ws As Worksheet
Dim pf As PivotField

Set wb = ActiveWorkbook

Application.ScreenUpdating = False
For Each ws In wb.Worksheets
    For Each pt In ws.PivotTables
        For Each pf In pt.PivotFields
            For Each pi In pf.PivotItems
                pi.Caption = pi.SourceName
            Next
        Next
    Next
Next
Application.ScreenUpdating = True
End Sub
0

If the column in question is already in several Pivots and there is some effort or troubles to re-add the column or you fear to destroy some layouts for example - then I propose the following easy way:

  • Rightclick anywhere in the pivot, select "Pivot Table Table Options", select the "Data" Tab and Change "Number of items to retain per Field" to none.
  • refresh the pivot

And there we go, old field label item ("aliases") are forgotten. You possibly want to rename the data aliaes back to where you want them, and possibly undo the "Number of items to retain per Field" to automatic.

Paschi
  • 940
0

Or just reset a single pivot item with some VBA code:

Sub ResetSinglePivotItemCaption()

Dim pivItem As PivotItem Set pivItem = Selection.Cells(1).PivotItem pivItem.Caption = pivItem.SourceName

End Sub

CentrixDE
  • 780
0

Another option, if you can't use the 'rename the original column' option for whatever reason:

First, clear Use Custom Lists when Sorting. i.e. Unset Pivot Table Options -> Totals & Filters -> Sorting: Use Custom Lists when Sorting

Then use Sort A-Z on the Row Labels.

This will put the pivot table into the 'right' order for the original labels.

As long as you know what the original labels are, you should now be able to restore them.

Just be aware that rows will jump around as you do - you might need to repeat the sort after making each change.

-1

you can allow excel to forget items it hasn't seen in the most recent update, then load a dummy table (select top 1 from ).

Some variant on this will work for all versions of excel.

http://www.contextures.com/xlPivot04.html