+ Reply to Thread
Results 1 to 13 of 13

refresh pivot table when data changes

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-28-2006
    Posts
    690

    refresh pivot table when data changes

    good morning all.

    I would like to automatically update my pivot table whenever I make changes to the raw data. I have tried:

    private sub worksheet_activate()
    run "pivotmacro"
    end sub

    and

    private sub worksheet_calculate()
    sheets("pivot").pivottables("pivottable1").refreshtable
    end sub

    but neither works......help

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Following code should help ...
    ( if Pivot Table is located in its own worksheet)

    Private Sub Worksheet_Activate()
    ActiveSheet.PivotTables("PivotTable1").RefreshTable
    End Sub
    HTH
    Carim
    Last edited by Carim; 11-28-2006 at 06:28 AM.

  3. #3
    Forum Contributor
    Join Date
    02-28-2006
    Posts
    690
    thanks Carim, I am very new at VBA, I have entered your code, but nothing happens, do I need to activate or run it, is it meant to refresh the pivot table continuously? On any data change would be ideal...

    Bob

  4. #4
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Go to worksheet tab
    right click
    select view code
    copy code

    that's it ...

    HTH
    Carim

  5. #5
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Robert,

    There are a couple of traps to avoid

    1. If the pivot table is located in the same worksheet as your data
    Private Sub Worksheet_Change(ByVal Target As Range)
    ActiveSheet.PivotTables("PivotTable1").RefreshTable
    End Sub
    2. Make sure the Name of your pivot table is "PivotTable1"
    While located in the pivot table, right click, select Table Options and correct the name, if need be ...

    HTH
    Carim

  6. #6
    Forum Contributor
    Join Date
    02-28-2006
    Posts
    690
    Many thanks, Carim, it works now, although the screen flickers for about a second after I change some base data, although I can see the new pivot total is correct from the outset. Data and pivot are in the same worksheet. If the flicker happens to you also, obviously I have to live with it.

    (only using test data at present, 2 cols by 10 rows)

    Bob

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1