Home > Topics > excel > body text

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

青灯夜游
Release: 2023-01-13 19:29:45
forward
15313 people have browsed it

This article will give you a summary of pivot table data refresh, and introduce three methods of dynamically refreshing data: VBA automatically refreshes pivot tables, super tables, and existing connections. There is always one of these refresh methods that suits you, and the operation is super simple. You can complete dynamic refresh with just a few clicks of a button. Remember to bookmark it!

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Pivot table is a commonly used skill in EXCEL, which can help us quickly statistically analyze large amounts of data. And as the layout changes, the pivot table will immediately recalculate the data according to the new arrangement, which is very practical in daily work. However, if the data source is added, the PivotTable cannot be updated synchronously. So today I will introduce to you several ways to dynamically refresh data in Excel pivot tables.

As shown in the figure, this data source lists sales in different cities.

excel vb刷新透视表

1. Basic refresh of pivot table

1. Select any cell in the table area and click under the Insert tab "Pivot table".

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

2. In the "Create Pivot Table" window, all contiguous areas are automatically selected in the table area. In order to facilitate viewing, put the Pivot Table location in the same work under the table. Click OK.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

#3. Now put "City" into the row label and "Sales" into the value range. For the convenience of comparison, subsequent creation is done in the same way.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Complete as follows:

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

4. Next, add the following data in the last row of the table. At this time, the total value is: The original 255418 became 258418.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

5. Select the Pivot Table, and the Pivot Table tool will appear above the menu bar. Click under the "Analysis" tab "refresh".

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

But the pivot table has not changed.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

#6. This situation is because the new row is not added to the data source area of ​​the pivot table, so the data source needs to be modified. Select the PivotTable and click "Change Data Source" under the "Analysis" tab below the PivotTable tool.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Then re-select the area in the table area of ​​the "Change PivotTable Data Source" window and select the new rows. The area is changed to "Sheet1!$A$1:$D$71".

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Just click refresh again.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Through this example, we found that if the data increases, the pivot table needs to change the data source to update, but in actual work, if Due to frequent data changes, is there any way to quickly refresh the Excel pivot table?

2. Excel pivot table dynamically refreshes data

1) VBA automatically refreshes the pivot table

1. Select the job Columns A to D of the table data, add a pivot table and put it in the same worksheet.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing DataThe settings are completed as follows:

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data2. Click Insert under the "Development Tools" tab, in the ActiveX control Command button, creates a button on the worksheet.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

If the form does not have the Development Tools tab, click File-Options, in the "Customize Ribbon" on the left side of the "EXCEL Options" window, select "Main Tab" Development Tools" is added to the custom ribbon on the right.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

#3. Right-click the button you just added in the worksheet and select "View Code". Enter the following code in the VBA window that pops up.

Private Sub
CommandButton1_Click()
ActiveSheet.PivotTables("数据透视表9").PivotCache.Refresh
End Sub
Copy after login

PivotTable 9 in the code is the name of the PivotTable.

4. Then click "Design Mode" on the Development Tools tab to cancel the design mode of the button. The button can be clicked normally.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

5. Add a row of data at the end of the worksheet data source as follows. After adding, the total value is 258418

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

6 .Then click the button to refresh, and the pivot table will be updated in real time.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Summary: This method includes other blank areas when selecting the data source, and it can be dynamically updated if data is added later. And adding a button through VBA makes the refresh operation more convenient. However, the problem is that once invalid data appears in other selected areas, the PivotTable will also include it.

2) Existing connections refresh the PivotTable

1. Click "Existing Connections" under the Data tab. Click "Browse More" in the pop-up window.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

2. Find the workbook in the "Select Data Source" window and click to open

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

In the "Select Table" window, find the worksheet where the data is placed and click "OK".

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

3. In the "Import Data" window, select the data to display in a pivot table. In order to facilitate viewing the effect, place it here on the existing worksheet. .

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Complete as follows:

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

4. Also add data in the last row as follows. After adding, the total value becomes 258418

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

5. Select the PivotTable, click the "Analysis" tab under the PivotTable tool, and click "Refresh". The pivot table will automatically refresh the data.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Summary: This method turns the EXCEL worksheet into a connection and inserts the pivot table through the connection. The advantage is that changes in the worksheet can be updated in time, but again, when we choose this method, the worksheet cannot put other data, and the pivot table should be built on other worksheets as much as possible to avoid errors.

3) Super table implements Excel pivot table refresh

1. Select any cell in the worksheet area, hold down Ctrl T, the table data in the following window The source will automatically select the worksheet area. The first row of the table here is the title, so check "Table contains title".

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

#2. Insert a pivot table based on this super table. Select any cell in the table range and insert a PivotTable report in the same worksheet. The table area will be set to the name of the supertable: Table 5.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

# Also put "City" in the row label and "Sales" in the value area. Complete as follows:

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

3. Add the following data in the last row of the table. After adding, the total value is 258418

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

4. Select the pivot table and click "Analyze" under the pivot table tool. ” tab and click “Refresh”. This achieves dynamic updating.

Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data

Super table is a function added since Excel2007. It solves the problem that the first two methods cannot intelligently select the data source area. Super table can automatically increase or decrease the data source area, which is its biggest advantage as a dynamic data source.

The methods have been introduced. Each of the above three methods has its own advantages and disadvantages. I hope you can choose flexibly according to the actual needs of your work. If you think it’s good, give me a like!

Related learning recommendations: excel tutorial

The above is the detailed content of Excel Pivot Table Learning: Three Methods of Dynamically Refreshing Data. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:itblw.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template