+ Reply to Thread
Results 1 to 3 of 3

Auto Refresh a Pivot Table

  1. #1
    Jonathan
    Guest

    Auto Refresh a Pivot Table

    How do I get a Pivot Table to automatically refresh when the data source (in
    the spreedsheet) is refresh.

    I am refreshing the data source from the value of a cell on the same sheet
    if that helps?

    Tia

  2. #2
    Nick Hodge
    Guest

    Re: Auto Refresh a Pivot Table

    Jonathan

    You could use the change of the cell to trigger a refresh. The code below
    should give you a start.

    It uses the worksheet_Change event, checking that the cell that changes is
    A2. If it is, it switches events off as the refresh will set another
    firing, it refreshes a pivot table called PivotTable2 and then switches
    events back on. make sure you switch this back on, probably by adding error
    checking to do this. If the refresh is successful it returns True. (You may
    not need this though)

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("A2")) Is Nothing Then
    Application.EnableEvents = False
    Me.PivotTables("PivotTable2").RefreshTable
    End If
    Application.EnableEvents = True
    End Sub

    --
    HTH
    Nick Hodge
    Microsoft MVP - Excel
    Southampton, England
    [email protected]HIS


    "Jonathan" <[email protected]> wrote in message
    news:[email protected]...
    > How do I get a Pivot Table to automatically refresh when the data source
    > (in
    > the spreedsheet) is refresh.
    >
    > I am refreshing the data source from the value of a cell on the same sheet
    > if that helps?
    >
    > Tia




  3. #3
    Jonathan
    Guest

    Re: Auto Refresh a Pivot Table

    Hi Nick,

    Thanks for the info but I think I didn't explain myself properly I don't
    want the Pivot Table to refresh based on the value of a cell I want the pivot
    table to refresh itself autmatically after the ODBC has been refreshed, does
    that make more sense?

    Regards


    Jonathan

    "Nick Hodge" wrote:

    > Jonathan
    >
    > You could use the change of the cell to trigger a refresh. The code below
    > should give you a start.
    >
    > It uses the worksheet_Change event, checking that the cell that changes is
    > A2. If it is, it switches events off as the refresh will set another
    > firing, it refreshes a pivot table called PivotTable2 and then switches
    > events back on. make sure you switch this back on, probably by adding error
    > checking to do this. If the refresh is successful it returns True. (You may
    > not need this though)
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > If Not Application.Intersect(Target, Range("A2")) Is Nothing Then
    > Application.EnableEvents = False
    > Me.PivotTables("PivotTable2").RefreshTable
    > End If
    > Application.EnableEvents = True
    > End Sub
    >
    > --
    > HTH
    > Nick Hodge
    > Microsoft MVP - Excel
    > Southampton, England
    > [email protected]HIS
    >
    >
    > "Jonathan" <[email protected]> wrote in message
    > news:[email protected]...
    > > How do I get a Pivot Table to automatically refresh when the data source
    > > (in
    > > the spreedsheet) is refresh.
    > >
    > > I am refreshing the data source from the value of a cell on the same sheet
    > > if that helps?
    > >
    > > Tia

    >
    >
    >


+ 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