Displaying a PivotTable's Name in the PivotTable

Written by Allen Wyatt (last updated November 19, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


David wonders if there is a way to display a PivotTable's name within the PivotTable itself.

The short answer is that there is no way to do this automatically. The longer answer is that you can "cheat" and force a name into the PivotTable. For instance, you could select the row label cell in the PivotTable and edit it (F2), replacing whatever is there with whatever name you want to type. This is far from automatic, and when you refresh the PivotTable, you'll need to remember to edit the cell again.

Another way to force a name into the PivotTable is to use a macro. There are probably a few approaches you could take in your macro. One approach is to create a data table on which your PivotTable will be based. Give the data table a heading, in the first column. (Any old text for the heading will do, as the macro will overwrite it.)

After you create your PivotTable, run the following macro. It determines the name of the PivotTable, stuffs it into the heading of the data table, refreshes the PivotTable (so the name appears there), and then updates the name of the PivotTable report filter so it is the same as the PivotTable name.

Sub GetPVName()
    Dim pvt As PivotTable
    Dim PVName As String

    ' Get the PivotTable name from the ActiveSheet
    ' If there are multiple PivotTables, this approach
    ' ensures the macro will work with the last PivotTable
    ' in the PivotTables collection
    For Each pvt In ActiveSheet.PivotTables
        PVName = pvt.Name
    Next pvt

    ' Put PivotTable name as a heading for the first
    ' column of the data table
    Range("Table1").Cells(0, 1) = PVName

    ' Refresh the PivotTable
    ActiveSheet.PivotTables(PVName).PivotCache.Refresh

    ' Set the PivotTable name in the report filter
    With ActiveSheet.PivotTables(PVName).PivotFields(PVName)
        .Orientation = xlPageField
        .Position = 1
    End With
End Sub

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3233) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

IEEE Citation Format

Different style guides describe different ways of formatting information that appears in a document. One such style guide ...

Discover More

Finding All Instances of a Value

Searching for information in an Excel worksheet generally goes very smoothly. There can be times, however, when the ...

Discover More

Ignoring Accented Characters in Searches

When writing in non-English languages, there can be many variations of accented characters that are used in a word. You ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Missing PivotTable Data

Wonder what happened to the data behind a PivotTable? It could be in a number of places, and tracking it down could be a ...

Discover More

Updating a PivotChart Automatically

If you expect your PivotCharts to update automatically when you update a PivotTables, you may want to alter, slightly, ...

Discover More

Default Formatting for PivotTables

Wish there was a way to define how you want PivotTables formatted before you actually create the PivotTable? You may be ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 + 7?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.