If you want to change the data source for a single Excel Pivot Table, you can use a command on the Ribbon. If you want to change data source for all pivot tables in a workbook, you can use a macro, instead of making the changes manually.
如果要更改单个Excel数据透视表的数据源,则可以在功能区上使用命令。 如果要更改工作簿中所有数据透视表的数据源,则可以使用宏,而不是手动进行更改。
更改数据源一个数据透视表 (Change Data Source One Pivot Table)
Follow these steps, to change the data source for a single pivot table.
请按照下列步骤操作,以更改单个数据透视表的数据源。
- Select a cell in the pivot table that you want to change 在数据透视表中选择要更改的单元格
- On the Ribbon, under PivotTable Tools, click the Options tab 在功能区上,在“数据透视表工具”下,单击“选项”选项卡
- Click the upper part of the Change Data Source command 单击“更改数据源”命令的上部

- When the Change PivotTable Data Source dialog box opens, press the F3 key on the keyboard, to open the Paste Name window. 当“更改数据透视表数据源”对话框打开时,按键盘上的F3键以打开“粘贴名称”窗口。
- Click on the named range that you want to use, and click OK 单击您要使用的命名范围,然后单击“确定”。

- Click OK to close the Change PivotTable Data Source dialog box. 单击“确定”关闭“更改数据透视表数据源”对话框。
更改工作簿中的所有数据透视表 (Change All the Pivot Tables in the Workbook)
If you have several pivot tables in a workbook, and want to change all of them to a new data source, you can use a macro, instead of making the changes manually.
如果工作簿中有多个数据透视表,并且想要将它们全部更改为新的数据源,则可以使用宏,而不是手动进行更改。
I've added a new page on the Contextures website – Excel Pivot Table Data Source – with sample code to update all the pivot tables.
我在Contextures网站上添加了一个新页面– Excel数据透视表数据源 –带有示例代码来更新所有数据透视表。
The macro adds a sheet to your active workbook, showing a list of the file's named ranges. Then, the macro prompts you to enter one of those names, as the new data source for all the pivot tables.
该宏将一个工作表添加到您的活动工作簿中,显示该文件的命名范围的列表。 然后,宏提示您输入这些名称之一,作为所有数据透视表的新数据源。

翻译自: https://contexturesblog.com/archives/2012/04/19/change-data-source-for-all-pivot-tables/