+ Reply to Thread
Results 1 to 1 of 1

Updating pivot tables automatically when leaving worksheet. Specific occurances only

Hybrid View

  1. #1
    Registered User
    Join Date
    04-01-2011
    Location
    Stamford, CT
    MS-Off Ver
    Excel 2003
    Posts
    31

    Updating pivot tables automatically when leaving worksheet. Specific occurances only

    I have a spreadsheet with multiple pivot tables all reading from one source. The source is on the tab "Waiver List"

    Each pivot table is on a separate tab within the same workbook.

    Currently, I have a code on the "waiver list" tab that updates all pivot tables whenever I leave that sheet. There's also a code that sorts the waiver list whenever I go to that tab.

    Here's the 2 codes:

    Private Sub Worksheet_Activate()
    
    ' run sort when spreadhseet is activated
    Waiver_List_Sort
    End Sub
    ____________________________________
    
    Private Sub Worksheet_Deactivate()
    
        'If the chart, workbook or worksheet is deactivated, refresh all pivot tables
    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
    What I WANT to do is to ONLY update the pivot tables when I leave the "Waiver List" tab AFTER/IF any changes are made. So if I just select the sheet, it sorts, but I don't add any new information, or change and data, I don't want the pivot tables to all refresh.

    Now, maybe this can't be done because it will read the sorting as changes being made, but maybe someone in here can help me out.

    I'm not a VBA pro, but I understand the general terms. If you need other information about the sheet let me know.
    Last edited by pike; 04-02-2011 at 04:34 AM. Reason: add code tags for newbie PM rule

+ 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