+ Reply to Thread
Results 1 to 3 of 3

Pivot Table(s) update macro workbook with locked sheets

  1. #1
    Registered User
    Join Date
    01-27-2015
    Location
    Southern Norway
    MS-Off Ver
    2010/2013 Std
    Posts
    17

    Pivot Table(s) update macro workbook with locked sheets

    Problem follows, hope it is Clear:
    -------------------------------------

    Sub UnprotectRefreshAll()
    Dim ws As Worksheet
    On Error Resume Next

    For Each ws In ActiveWorkbook.Worksheets
    ws.Unprotect Password:=""
    Next ws

    ActiveWorkbook.RefreshAll

    For Each ws In ActiveWorkbook.Worksheets
    ws.Protect Password:="", _
    AllowUsingPivotTables:=True
    Next ws

    End Sub

    ' 1. Getting error message on opening workbook, because:
    ' I have 2 (locked) sheets with different Pivot Tables based on same source data!
    ' NOTE All sheets are locked, not Workbook
    '
    ' BUT:
    ' 2. When I run this macro from an "Update" Button,in either of the Pivot sheets
    ' -the macros are executed despite the error message
    ' -but the last referenced sheet is opened! (ARTICLES)
    ' (Sheets CUSTOMER1-CUSTOMER2-TOTALS(Pivot)-ANALYSIS(Pivot)-CUSTOMERS-ARTICLES)
    ' "ARTICLES" is opening....

    ' 1. Don't understand, as the macro is executing anyway. ?
    ' 2. What I am missing is a substitute, or an addition to, "Next ws". ?
    ' 3. NOTE that macro is excecuting correct whwn RUN, but lands on last sheet from BUTTON.
    Last edited by torers; 06-11-2015 at 11:10 AM.

  2. #2
    Registered User
    Join Date
    01-27-2015
    Location
    Southern Norway
    MS-Off Ver
    2010/2013 Std
    Posts
    17

    Re: Pivot Table(s) update macro workbook with locked sheets

    I have (partially) answered my own Qs:

    1. Reason for error message: (Cannot refresh pivot table while sheet is protected)

    "Pointing to a different sheet, means that each one of them is using a different pivot cache, which although different is of the same size on each sheet, which was exactly what was causing the problem
    Changing the pivot source of each pivot table to include just one row more than the previous one solves it. (Citation from contributor "wakeupcall"). Now to relearn Pivot details....


    2. Macro updating button in one (of 2) Pivot Table sheets opens irrelevant last sheet-
    REPLACED macro button with ACTIVEX ditto, both tables updated and remains on Pivot Table sheet 1.

    RGDS

  3. #3
    Registered User
    Join Date
    01-27-2015
    Location
    Southern Norway
    MS-Off Ver
    2010/2013 Std
    Posts
    17

    Re: Pivot Table(s) update macro workbook with locked sheets

    I have a simple solution for Question 1, it seems:
    -Pivot Table Alternatives
    -Data
    -Uncheck "Update on opening file"

    This of course may depend on other circumstances. In my case I only have the 2 table sheets to update, taken care of by the Update ACTIVEX on sheet 1

    NOTE:
    -Workbook not locked, sheets only

    Tested on Excel 2013 Home/Office 2010 PRO

    Comments?

+ 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. vba code to update all pivot table in workbook but file size is ( 100 mb )
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2014, 06:23 AM
  2. Can you update a pivot table using a drop-down without a macro?
    By somedudeonline in forum Excel General
    Replies: 0
    Last Post: 07-23-2013, 06:16 PM
  3. Replies: 3
    Last Post: 06-28-2010, 04:28 AM
  4. Update Pivot Table with New Sheets
    By WRPCWill in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2008, 10:57 PM
  5. how to update a pivot table on shared workbook
    By EED in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-17-2005, 09:05 AM

Tags for this Thread

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