Forum Discussion

Chris525's avatar
Chris525
Copper Contributor
Apr 01, 2024
Solved

Auto Refresh for Pivot tables created on sheets (Master data also on the same sheet)

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

 

 

 

 

  • Chris525 

    Click 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 

13 Replies

  • Chris525 

    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)

    • Chris525's avatar
      Chris525
      Copper Contributor

      HansVogelaar 

      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

      • Chris525 

        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.

Resources