+ Reply to Thread
Results 1 to 5 of 5

Refreshing pivot tables in a protected sheet

  1. #1
    Registered User
    Join Date
    03-04-2020
    Location
    Boston,MA
    MS-Off Ver
    Excel for Office 365
    Posts
    3

    Refreshing pivot tables in a protected sheet

    Hello all,

    I have a workbook which has 2 sheets in it. One has a large amount of source data and in the other sheet I've created a set of 10 pivot tables which is fed from the source data sheet. I wanted to have the pivot tables update based upon changes to the source data using a Macro/VBA and I've found that using "ThisWorkbook.RefreshAll" works like a charm. However, I'd now like the sheet with the pivot tables to be protected from changes after the data refreshes. I'm guessing there is a better code to use in Macros/VBA but I've not been able to put my finger on it after many many web searches. Does anyone know the best code to achieve this? If anyone here has the answer to this question I'd be most appreciative!

    Best,
    Jenn

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Refreshing pivot tables in a protected sheet

    Hi Jenn,

    In your vba what if you unprotected the sheet then refreshed all and then protected it again. This would only be done when you added stuff to your main data. Is that an idea you could work with?

    I'm not sure what you are protecting you sheet from. Could you explain?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-04-2020
    Location
    Boston,MA
    MS-Off Ver
    Excel for Office 365
    Posts
    3

    Re: Refreshing pivot tables in a protected sheet

    Hi Marvin,

    Thanks so much for responding! I tried modifying my VBA code to start with unprotect, run the refresh (using ThisWorkbook.RefreshAll) and then protect but it seems that the "ThisWorkbook.RefreshAll" code is linked to both the sheets in my workbook and it didn't work to refresh the pivot tables and then it locked the source data sheet which I don't want. I want to keep the source data sheet unprotected at all times so people can enter data in it but I want to protect the pivot tables sheet so that people entering data into the source sheet don't inadvertantly modify the pivot table structure. I hope this makes sense. I have a feeling I need to use different lines of code to do this but I just can't put my finger on what the code is when Googling this scenario. Any additional help or advice would be awesome.

    Thanks much
    Jenn

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Refreshing pivot tables in a protected sheet

    Hi Jenn,

    It sounds like you need to protect the worksheet and not the whole workbook. I believe there is two different commands?

    https://www.exceldemy.com/excel-work...el-protection/

    To see if there is a difference, turn on the "Record Macro" and do both to see what words VBA needs to do those functions. Look at the Module to see those words/objects/methods.

    Marv

  5. #5
    Registered User
    Join Date
    03-04-2020
    Location
    Boston,MA
    MS-Off Ver
    Excel for Office 365
    Posts
    3

    Re: Refreshing pivot tables in a protected sheet

    Hi again Marv,

    Thank you so much! I had not worked with Macros/VBA in many years so I completely forgot you can record a Macro and it will record the code for you.
    I just did this and then created a button in my sheet which updates the data from one sheet to another and then re-protects the sheet as the final step,
    and it worked like a charm!! This final feature put the finishing touches on my Excel project and I'm ready to present it to my client tomorrow! Thanks again!

    Best,
    Jenn

+ 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. [SOLVED] Refreshing Pivot Tables
    By Yoepy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-25-2018, 07:53 PM
  2. Refreshing PowerQuery Tables on a Protected Sheet
    By boxahoy in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-20-2017, 07:26 AM
  3. enable OLAP pivot tables in protected sheet
    By sanel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2014, 11:58 AM
  4. Refreshing pivot tables..
    By geliedee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2013, 12:32 AM
  5. Refreshing a Pivot is a protected worksheet
    By paulary30 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-12-2013, 01:37 PM
  6. Excel 2007 : Refreshing Pivot Tables
    By muralikreddy in forum Excel General
    Replies: 3
    Last Post: 06-17-2010, 06:15 AM
  7. Refreshing pivot tables
    By matpj in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2006, 11:40 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