How to Update Pivot Table Range (5 Methods)

The sample dataset contains the Product Category, Quantity and Sales per State.

 

Dataset

 

The dataset is configured as a Pivot Table.

Pivot Table of Existing Dataset

In addition three new rows of data have been added to the dataset which will be updated in the Pivot Table.

Dataset with New Data

 


Method 1 – Updating the Pivot Table Range Manually by Changing the Data Source

 

 

  •  Select a cell within the Pivot Table.
  • Click on the PivotTable Analyze option in the ribbon, then select Change Data Source and then Change Data Source…

Updating Pivot Table Range Manually

  •  Move PivotTable option will appear, then change the Table/Range to $B$4:$E$15, and press OK.

Updating Pivot Table Range Manually

  • The Pivot Table will be updated.

Updating Pivot Table Range Manually

Read more: Automatically Update a Pivot Table When Source Data Changes in Excel


Method 2 – Updating Pivot Table Range by Clicking the Refresh Button

Select a cell within the Pivot Table and then right-click on the mouse or press ALT+F5 then select Refresh from the menu of available options.

 

Updating Pivot Table Range by Clicking the Refresh Button

The Pivot Table will update automatically.

Updating Pivot Table Range by Clicking the Refresh Button

Read more: How to Refresh All Pivot Tables in Excel


Method 3 – Updating a Pivot Table Range by Converting to an Excel Table

 

Steps:

  • Select a cell within the dataset and insert a table by clicking the Insert tab > Table.

How to insert a table

  • Alternatively use the CTRL+T keyboard shortcut to create a table.

 

Creating a table in Excel

  • In the Create Table dialog box enter the Table range (here: $B$4:$E$12) and also check the box My table has headers.

 

Creating a table in Excel

⏩ Now we have to insert a Pivot Table for the above table.

⏩ Make sure the Table/Range is Table1 and press OK.

Creating a Pivot Table in Excel

⏩ Thus, we have created a dynamic Pivot Table range.

⏩ If we input any new data, the above Pivot Table will update automatically including the data.

For example, we want to add the following 3 rows.

New Data to Update

⏩ Then if you select a cell within the Pivot Table, and do right-click on the mouse, and then choose the Refresh option (or press ALT+F5).

Updating Pivot Table Range by Converting to Excel Table

⏩ So, the output will be as follows with the new column Arizona state.

Updating Pivot Table Range by Converting to Excel Table

Read more: How to Auto Refresh Pivot Table without VBA in Excel


Method 4 – Updating Pivot Table Range Utilizing the OFFSET Function

To create a dynamic range to update the Pivot Table automatically, the Name Manager can be used in combination with OFFSET and COUNTA functions.

Steps:

  •  Click on the Formulas tab > Name Manager option from the Defined Names ribbon.
  •  A Name Manager dialog box will appear.
  •  Click on the New option.

Updating Pivot Table Range Utilizing the OFFSET Function

  • Set the Name as Source_Data and insert the following formula in the Refers to box
=Dynamic_Range!$B$4:$E$15_Range!$B$4,0,0,COUNTA(Dynamic_Range!$B:$B),COUNTA(Dynamic_Range!$4:$4))

Here, the current sheet name is Dynamic_Range, $B$4:$E$15 is the raw data, B4 is the starting cell of the data, $B:$B is column B and $4:$4 is row 4.

Updating Pivot Table Range Utilizing the OFFSET Function

  • Click OK.
  • In the next dialog box that appears, enter Source_Data in the Table/Range.

Updating Pivot Table Range Utilizing the OFFSET Function

 

  • Click OK to return a new Pivot Table.

Updating Pivot Table Range Utilizing the OFFSET Function

Note: If the Table/Range option is not correct, Excel will return a message “the data source is not valid” and no Pivot Table will be created.

 

  • If we input new data into the raw data table, the Pivot Table will update automatically.

 

Updating Pivot Table Range Utilizing the OFFSET Function

  •  After adding new data to the dataset press ALT+F5 in the Pivot Table to make it appear here.

 

Updating Pivot Table Range Utilizing the OFFSET Function


Method 5 – Updating Pivot Table Range Using VBA Code

 

Step 1: 

Open a module by clicking Developer > Visual Basic.

How to Insert VBA Code

Double-click on the Sheet10.

Step 2: 

Private Sub Worksheet_Deactivate()
 Sheet9.PivotTables("PivotTable10").PivotCache.Refresh
End Sub

VBA Code for Updating Pivot Table Range

Step 3:

Run the code.

Notes:

  • The raw data is saved in Sheet10 (Dataset_VBA).
  • The Pivot Table is saved as Sheet9 (PivotTable_VBA).
  • Copy the default name of Pivot Table eg PivotTable10.

After changing the sales in the dataset, the Pivot Table now updates automatically.

Updating Pivot Table Using VBA code

 

Updating Pivot Table Range Using VBA Code

It is important to note that the Macro cannot retrieve undo history data. To do this the Refresh the data when opening the file option must be turned on.

  • To do this, click PivotTable Analyze > Options.

Pivot Table option

  • Check the Refresh the data when opening the file option.

Pivot Table Options

 

  • Click OK.

Download Practice Workbook

 


Related Articles


Get FREE Advanced Excel Exercises with Solutions!
Md. Abdul Kader
Md. Abdul Kader

MD. ABDUL KADER is an engineer with a talent for Excel and a passion for VBA programming. To him, programming is like a time-saving wizard, making data manipulation, file handling, and internet interactions a breeze. His skill set extends to SWM, GIS, RS, and SPSS. He holds a B.Sc in Urban & Regional Planning from Chittagong University of Engineering and Technology and has shifted to become a content developer. In this role, he crafts technical content centred around... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo