+ Reply to Thread
Results 1 to 4 of 4

Refresh Pivot tables in protected worksheet - Automatically

Hybrid View

  1. #1
    Registered User
    Join Date
    12-23-2015
    Location
    Montenegro, Podgorica
    MS-Off Ver
    2010
    Posts
    6

    Refresh Pivot tables in protected worksheet - Automatically

    Hi Everyone,

    In a workbook with multiple pages, there is one with 2 pivot tables that needs to have functionality of automatic refresh when you come to that page (simply by shifting pages).
    Currently, I do have a code that does that, however it needs to be upgraded/changed in order to allow the same thing, but in protected sheet.
    On top of pivot tables there will be predicted fields that can be subject of the change in protected sheet (i.e. "unlocked"), however I don't want to allow any modification of the remained cells, nor pivot table itself (by including/excluding fields for example).

    Attached is document with code (and detailed guidance).

    Does someone know how this can be done?

    Many thanks,
    Tebr
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,252

    Re: Refresh Pivot tables in protected worksheet - Automatically

    Try replacing the procedure with the following:
    Private Sub Worksheet_Activate()
        Dim pt          As PivotTable
    
        Me.Unprotect Password:=""
    
        Application.EnableEvents = False
    
        For Each pt In Me.PivotTables
            pt.RefreshTable
        Next pt
    
        Me.Protect Password:="", DrawingObjects:=True, _
                   Contents:=True, Scenarios:=True, _
                   AllowUsingPivotTables:=True
    
        Application.EnableEvents = True
    End Sub
    Artik

  3. #3
    Registered User
    Join Date
    12-23-2015
    Location
    Montenegro, Podgorica
    MS-Off Ver
    2010
    Posts
    6

    Re: Refresh Pivot tables in protected worksheet - Automatically

    Thanks Artik, this is close, but PivotTable Fields are modifiable which I don't want. Is it possible to remove/protect/hide "Field List" for example, or something similar?

    Tebr
    Attached Images Attached Images

  4. #4
    Registered User
    Join Date
    12-23-2015
    Location
    Montenegro, Podgorica
    MS-Off Ver
    2010
    Posts
    6

    Re: Refresh Pivot tables in protected worksheet - Automatically

    I've figured it out. Replace AllowUsingPivotTables:=True, with AllowUsingPivotTables:=False
    Then it works smoothly.

    Thanks a lot.

    Tebr

    Private Sub Worksheet_Activate()
        Dim pt          As PivotTable
    
        Me.Unprotect Password:=""
    
        Application.EnableEvents = False
    
        For Each pt In Me.PivotTables
            pt.RefreshTable
        Next pt
    
        Me.Protect Password:="", DrawingObjects:=True, _
                   Contents:=True, Scenarios:=True, _
                   AllowUsingPivotTables:=False
    
        Application.EnableEvents = True
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. refresh pivot tables while sheets are protected
    By LeeRichard in forum Excel Charting & Pivots
    Replies: 11
    Last Post: 08-02-2014, 04:24 AM
  2. Refresh pivot tables on one worksheet, not all
    By jl22stac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-06-2013, 08:48 PM
  3. [SOLVED] Refresh all pivot tables automatically when a cell value changes
    By ANS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-11-2013, 04:41 AM
  4. VBA to refresh all pivot tables on all protected worksheets
    By ef67 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-19-2013, 04:39 PM
  5. Refresh pivot table on a protected worksheet
    By DougieL in forum Excel General
    Replies: 2
    Last Post: 08-09-2012, 02:10 AM
  6. Updating pivot tables automatically when leaving worksheet. Specific occurances only
    By DMBeer41 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-01-2011, 11:51 AM
  7. Automatically refresh pivot tables after data entry
    By Hodgepodge in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2011, 06:27 AM

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