Mar 31 2024 09:07 PM
Hi
Kindly suggest me a way to refresh the pivot tables created in excel automatically
Sheet 1 - Main Data (We update daily)
Sheet 2 - Pivot tables
How can I refresh the pivot tables on sheet 2 when we add new rows to sheet 1.
Many Thanks
Apr 01 2024 02:56 AM
If the source data are not in a table, convert the range to a table, then set the source range of the pivot tables to that table. That way, new rows added to the table will automatically be included in the pivot table source.
Right-click the sheet tab of Sheet 2.
Select View Code from the context menu.
Copy the following code into the worksheet module:
Private Sub Worksheet_Activate()
Me.PivotTables(1).PivotCache.Refresh
End Sub
Each time you switch to Sheet 2 to view the pivot tables, they will automatically be updated.
Save the workbook as a macro-enabled workbook (*.xlsm)
Apr 01 2024 03:19 AM
I tried to add the code., but couldn't achieve the expected output.
Herewith attached a draft datasheet. Can you kindly check and support?
Sorry I'm unable to attach the file .
Thanks
Apr 01 2024 03:49 AM
If you cannot attach a workbook, please upload it to a cloud service such as Google Drive or OneDrive, obtain a link and post the link in a reply.
Apr 01 2024 04:03 AM
Thank you for letting me know.
Please find the link. Hope you can open the file
Thanks
Apr 01 2024 04:35 AM
Thanks. See the attached version.
Apr 01 2024 04:40 AM
Apr 01 2024 04:49 AM
I converted the source range to a table, and set the pivot tables to refer to the table instead of to a fixed range,
Apr 01 2024 04:52 AM
Thank you!!
Sorry one more question how did you set the pivot tables to refer to the table instead of to a fixed range?
Can you kindly suggest me any tutorials I can refer regarding this subject?
Thanks
Apr 01 2024 04:59 AM
SolutionClick in a pivot table.
Activate the PivotTable Analyze tab of the ribbon.
Click 'Change Data Source'.
Either type the name of the table, or click in the box, then activate the sheet with the source table, and select the entire table. Excel should automatically replace the range address with the name of the table.
Click OK.
See for example 5 Reasons to Use an Excel Table as the Source of a Pivot Table
Apr 01 2024 08:13 PM
Apr 02 2024 12:23 AM
Another question, the file was already uploaded and shared on SharePoint with others. How can I make the changes (Those pivot tables) and save as macro file?
Please advice.
Thanks
Apr 02 2024 01:30 AM
I'm not an expert on SharePoint, I cannot help you with that. Sorry!
Apr 02 2024 01:31 AM
Apr 01 2024 04:59 AM
SolutionClick in a pivot table.
Activate the PivotTable Analyze tab of the ribbon.
Click 'Change Data Source'.
Either type the name of the table, or click in the box, then activate the sheet with the source table, and select the entire table. Excel should automatically replace the range address with the name of the table.
Click OK.
See for example 5 Reasons to Use an Excel Table as the Source of a Pivot Table