Results 1 to 7 of 7

Thread: Automatically refresh pivot table on MS excel

  1. #1
    Join Date
    May 2011
    Posts
    62

    Automatically refresh pivot table on MS excel

    I am having the computer with processor core i7 and the operating system in my computer is windows 7. And I have the problem I want to make the pivot Tables but there is a minor difficulty that means I want to make the pivot Tables but it will automatically refreshes when some date has been changed. I have done it with the help of the macro the syntax is as follows:
    Code:
    Private Sub Worksheet Activate ()
    ActiveWorkbook.RefreshAll
    End Sub
    Si this is the syntax that I have created in the macro but hoe to modify the macro so that the pivot table would automatically refreshes itself when it has been changed. Please help me in creating the pivot tables that automatically refreshes. Thanking in advanced.

  2. #2
    Join Date
    Jun 2009
    Posts
    1,518

    Re: Automatically refresh pivot table on MS excel

    I was also thinking of this so I created the code and I think that you should run the code in the worksheet_Calculate Event and the code is as follows:
    Code:
    Private Sub Worksheet_Calculate () 
        Dim mh As PivotTable 
         
        Application.EnableEvents = False 
        For Each mh In Me.PivotTables: mh.RefreshTable: Next pt 
            Application.EnableEvents = True 
    End Sub
    This code will help you to solve the problem.

  3. #3
    Join Date
    Nov 2008
    Posts
    1,514

    Re: Automatically refresh pivot table on MS excel

    I think that the code for the raw data sheet should be as per you only have to mh it as the opposed to the raw data. The code is as follows:
    Code:
    Private Sub Worksheet_Calculate () 
    Dim mh As PivotTable      
    Application.EnableEvents = False 
    For Each mh In Sheets ("PivotTable").PivotTables: mh.PivotCache.Refresh: Next pt 
    Application.EnableEvents = True 
    End Sub
    So this code should reside above the raw data sheet and the object should be in the VBE and it should not be in the Pivot table.

  4. #4
    Join Date
    Mar 2009
    Posts
    1,360

    Re: Automatically refresh pivot table on MS excel

    I would like to write the full code in the expanding order such as the one which is using the Change event. An in this case it will refresh and the pivot tables on the worksheet. In this case the macro would be residing on each of the desire the coding is as follows:
    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim mh PivotTable
        Dim hmk  As Worksheet
        Application.EnableEvents = False
        For Each hmk In Application.Worksheets
            For Each mh In hmk.PivotTables
                mh.PivotCache.Refresh
               ' MsgBox ("Refreshed pivot table '" & mh.Name & "' in sheet '" & hmk.Name & "'.")
               ‘Use above line only for testing/confirmation.
            Next mh
        Next hmk
        Application.EnableEvents = True
    End Sub

  5. #5
    Join Date
    Nov 2008
    Posts
    1,259

    Re: Automatically refresh pivot table on MS excel

    From the discussion going on I think that you have to open the pivot table and after that you have to right click on the “pivot table option” which is in the popup menu and after the window is open in the pivot table then you have to just select the data tab and after that you have to check the checkbox called "Refresh data when opening file". And after that click on the OK button. And this will automatically refreshes the pivot table this is the simple and also an easy method.

  6. #6
    Join Date
    Nov 2008
    Posts
    1,185

    Re: Automatically refresh pivot table on MS excel

    There are several another “events” that are available in the spreadsheet and this you can be able to place this in the VBA code and after that you can be able to refresh the pivot table and after that when the "Worksheet_Calculate" event fires. You have to just use the macro code it is as follows:
    Code:
    Private Sub Worksheet_Calculate ()
        'If data on this worksheet changes, refresh the pivot table
        Sheets ("Pivot").PivotTables ("PivotTable1").Refresh Table
    End Sub

  7. #7
    Join Date
    Nov 2008
    Posts
    1,221

    Re: Automatically refresh pivot table on MS excel

    You can try this you have to just right click on the worksheet that is having the source code and the pivot table and then you have to select the view code option. This will help you with the view code and this will associate a particular sheet and the type of sheet is like this
    Code:
    Private Sub Worksheet_Change (ByVal Target As Range)
    Me.PivotTables(1).Refresh Table
    End Sub
    I hope that this will solve the problem.

Similar Threads

  1. How to sort multiple columns in Excel Pivot Table
    By Nicoloid in forum MS Office Support
    Replies: 2
    Last Post: 17-02-2012, 08:01 PM
  2. How to calculate filed different in Excel Pivot Table
    By YajasK in forum MS Office Support
    Replies: 2
    Last Post: 10-02-2012, 05:20 PM
  3. How to unpivot the pivot table in excel
    By Raju Chacha in forum MS Office Support
    Replies: 2
    Last Post: 08-01-2012, 03:13 PM
  4. To convert a pivot table to a flattened table in MS Excel
    By zeemga in forum Windows Software
    Replies: 3
    Last Post: 27-11-2010, 06:48 AM
  5. Pivot Table in Excel 2007
    By NIcaBoy in forum Windows Software
    Replies: 2
    Last Post: 02-03-2009, 03:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,299,271.89270 seconds with 17 queries