+ Reply to Thread
Results 1 to 2 of 2

pivot table doesn't update on sheet active

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    pivot table doesn't update on sheet active

    I am very new to VBA
    I took these instructions off the Pearson site

    First I tried to go to the VBEditor - Insert - Module & paste it
    Then I tried to Rt click on the Sheet Tab - View Code & paste it
    then I put the first half on the sheet tab and the second half into the VBEditor

    My pivot table still doesn't update automatically
    what am I doing wrong?


    Sub Auto_Open()
    Application.OnSheetActivate = "UpdateIt"
    End Sub

    Sub UpdateIt()
    Dim iP As Integer
    Application.DisplayAlerts = False
    For iP = 1 To ActiveSheet.PivotTables.Count
    ActiveSheet.PivotTables(iP).RefreshTable
    Next
    Application.DisplayAlerts = True
    End Sub
    Last edited by carsto; 11-29-2006 at 02:32 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    Delete the Sub Auto_Open() as you don't need it.

    Take your Sub UpdateIt() code and rename it

    Private Sub Worksheet_Activate()

    Your code will currently be on a module called something like Module1. Look in the project window (top left corner of VBA). Above the module folder is the Microsoft Excel Objects folder. Find the sheet that has all your pivot tables on it. Double click to open the code window in the right hand pane, then paste the Worksheet_Activate() code in that module.

    Matt

+ 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