+ Reply to Thread
Results 1 to 4 of 4

Thread: Refresh Pivot table based on condition

  1. #1
    Registered User
    Join Date
    09-29-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    90

    Refresh Pivot table based on condition

    Is it possible to not let user Refresh Pivot tables unless a condition is satisfied?. Condition may be as simple as a cell containing a specific data.

  2. #2
    Forum Guru jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    2,573

    Re: Refresh Pivot table based on condition

    You could try something like this...

    Sub PivotMacro()
        Dim pt As PivotTable
        If Sheet1.Range("A1").Value = "Update PT" Then
            Set pt = ActiveSheet.PivotTables("MyPivot")
            pt.RefreshTable
        End If
    End Sub
    HTH
    Regards, Jeff

    If you like the answer(s) provided, why not add some reputation by clicking the * below
    Please use [ Code ] tags when posting [ /Code ]
    Please view/read the Forum rules --- How to mark a thread as solved

  3. #3
    Registered User
    Join Date
    09-29-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    90

    Re: Refresh Pivot table based on condition

    Thanks Jeff. I have like 10 pivot tables in a worksheet. However, I do not want the user to refresh it unless the data is generated in the source worksheet.

    Is there way to do it for all the pivot tables or would it be efficient to put in a condition to active the pivot table worksheet only if a condition is met?

    Thanks,
    Booo

  4. #4
    Forum Guru jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    2,573

    Re: Refresh Pivot table based on condition

    You could use something like this...

    Sub AllWorkbookPivots()
    Dim pt As PivotTable
    Dim ws As Worksheet
        For Each ws In ActiveWorkbook.Worksheets
            For Each pt In ws.PivotTables
                        pt.RefreshTable
            Next pt
        Next ws
    End Sub
    HTH
    Regards, Jeff

    If you like the answer(s) provided, why not add some reputation by clicking the * below
    Please use [ Code ] tags when posting [ /Code ]
    Please view/read the Forum rules --- How to mark a thread as solved

+ 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.2.0