Consulting

Results 1 to 4 of 4

Thread: Refreshing Pivot Tables

  1. #1
    VBAX Newbie
    Joined
    Sep 2008
    Posts
    2
    Location

    Refreshing Pivot Tables

    Hi,

    I'm trying to create a macro button to refresh 'any' pivot table - preferablly keeping the macro in my personal workbook.

    However, when I Have created it:

    [VBA]Sub Refresh_pivot()
    ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
    End Sub[/VBA]

    It does not work if there are more than one pivot tables to a workbook. I'm certain it has something to do with the infomation in the () but I dont know how to change this to include 'any' pivot. It's probably REALLY simple - but I'm relatively new to macro creating.

    Please help if you can.

    Thanks in advance

    Teresa

  2. #2
    VBAX Regular
    Joined
    Sep 2008
    Posts
    36
    Location
    Try this:

    [VBA]Sub Refresh_Pivot()
    Dim t as integer
    For t = 1 to ActiveSheet.PivotTables.Count
    ActiveSheet.PivotTables(t).PivotCache.Refresh
    Next t
    End Sub[/VBA]

    Quote Originally Posted by Treeza
    Hi,

    I'm trying to create a macro button to refresh 'any' pivot table - preferablly keeping the macro in my personal workbook.

    However, when I Have created it:

    Sub Refresh_pivot()
    ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
    End Sub

    It does not work if there are more than one pivot tables to a workbook. I'm certain it has something to do with the infomation in the () but I dont know how to change this to include 'any' pivot. It's probably REALLY simple - but I'm relatively new to macro creating.

    Please help if you can.

    Thanks in advance

    Teresa

  3. #3
    VBAX Newbie
    Joined
    Sep 2008
    Posts
    2
    Location
    Thank you so much Slyboots! :o)

  4. #4
    VBAX Regular
    Joined
    Apr 2008
    Posts
    65
    Location
    I have several pivottables in each workbook but they all use the same pivotcache. I started out by refreshing each pivottable but that caused the pivotcache to re-load for every pivottable.

    That's probably not a problem if you don't have much data but we sometimes have over a gigabyte. So I just refresh one pivottable, the pivotcache reloads one time, but ALL the pivottables change to show the new values.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •