+ Reply to Thread
Results 1 to 9 of 9

Protect the sheet but allow pivot table to be used

  1. #1
    Registered User
    Join Date
    12-20-2018
    Location
    California, USA
    MS-Off Ver
    Windows 10
    Posts
    4

    Post Protect the sheet but allow pivot table to be used

    Hello,

    I am trying to protect a sheet such that the options Select Unlocked Cells and Use PivotTable & PivotChart are enabled via VBA.

    I tried to use
    Please Login or Register  to view this content.
    but nothing happens andthe sheet stays unprotected. Is there anyone that can point me to the right direction? Thanks.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Protect the sheet but allow pivot table to be used

    Hi and welcome to the forum.

    Maybe


    Please Login or Register  to view this content.
    Note it's good practice to use the VBA Sheet Code name rather than the sheet Tab name since they are too easily changed by users and if so your macro wll crash.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    12-20-2018
    Location
    California, USA
    MS-Off Ver
    Windows 10
    Posts
    4

    Re: Protect the sheet but allow pivot table to be used

    Hello,

    Thanks, glad to be here!

    Quick question, is the Sheet Code the sheet number? So if the pivot table is on sheet 2 then it would be With Sheet2 End With?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Protect the sheet but allow pivot table to be used

    No,

    The Sheet VBA Code Name is the name you see in the VBA Project area which lists the sheet objects, the Workbook object and any Modules you might have used.

    It will look like

    Sheet1(sheet_tab_name)

    The code name is the first bit not in parentheses.

  5. #5
    Registered User
    Join Date
    12-05-2018
    Location
    Philippines
    MS-Off Ver
    2013
    Posts
    4

    Re: Protect the sheet but allow pivot table to be used

    Hi Spyridion,

    There are two name attribute for worksheet
    1. Name that is visible and can be adjust by user
    2. Name that is visible and adjustable only inside code window

    sheetname.JPG

    On the above example (please look very closely on highlighted part), I have sheet named "Sheet3", while i change its other name to "wsData".

    Either Sheet3 or wsData I can use to code, BUT using sheet3 may fail due to user may change its name, use wsData instead

  6. #6
    Registered User
    Join Date
    12-20-2018
    Location
    California, USA
    MS-Off Ver
    Windows 10
    Posts
    4

    Re: Protect the sheet but allow pivot table to be used

    Hello,

    Oh, I see. I get it now. Thanks!

    Richard Buttrey - I have tried your suggestion of using EnableSelection but I'm locking the entire table now as I am getting a cannot edit PivotTable on Protected Sheet message when I try to click on a slicer. This is greatly confusing me as the Allow using Pivot Tables option is set to true.
    Last edited by Spyridion; 12-20-2018 at 08:44 PM.

  7. #7
    Registered User
    Join Date
    12-05-2018
    Location
    Philippines
    MS-Off Ver
    2013
    Posts
    4

    Re: Protect the sheet but allow pivot table to be used

    Try this code

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-20-2018
    Location
    California, USA
    MS-Off Ver
    Windows 10
    Posts
    4

    Re: Protect the sheet but allow pivot table to be used

    Thanks mhovidz! That worked. I just had to remove allow filtering.

  9. #9
    Registered User
    Join Date
    12-05-2018
    Location
    Philippines
    MS-Off Ver
    2013
    Posts
    4

    Re: Protect the sheet but allow pivot table to be used

    Happy to help

+ 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. Allow new data to be added to a protect pivot table
    By McGnity in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 08-31-2018, 01:31 PM
  2. Need to protect sheet and disable "select Locked Cells" on pivot table
    By Murman01 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-20-2017, 06:46 PM
  3. Protect Sheet but enable user to ONLY use pivot table slicers
    By dluhut in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-26-2016, 02:34 AM
  4. [SOLVED] Protect pivot table BUT allow it to refresh data?
    By ThomasCarter in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 11-07-2012, 12:30 PM
  5. Pivot table protect
    By guy_tayeb in forum Excel General
    Replies: 1
    Last Post: 07-06-2009, 07:23 AM
  6. Protect Pivot table queries
    By Sharon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-12-2006, 11:50 AM
  7. Pivot table with protect workbook
    By kalz in forum Excel General
    Replies: 1
    Last Post: 03-09-2006, 11:00 PM

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