Protect sheet and disable manual edits to pivot table but allow Slicers

ardykav

Board Regular
Joined
Oct 18, 2015
Messages
172
Office Version
  1. 365
Platform
  1. Windows
Not sure if this is possible but what i want to do is as follows:
Unprotect sheet, refresh data on pivot table on sheet, filter out 3 items and then protect sheet.
However after the sheet is protected I want it to be editeable by a Slicer but the user cannot manually override any data in the pivot table.

VBA Code:
Sub Protectandset()

    Dim DialogMsg As Integer
    Dim wb As Workbook
    Dim ms As Worksheet
    Dim st As Worksheet
 
       
     
    
    Set wb = ActiveWorkbook
    Set st = wb.Sheets("Source")
    Set ms = wb.Sheets("Summary")
    'emptyvalue = ""
    ms.Unprotect ("password123")
     Range("B4").Select
    ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Production Order Number"). _
        ClearAllFilters
    With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
        "Production Order Number")
        .PivotItems("").Visible = False
        .PivotItems("(blank)").Visible = False
        .PivotItems("Break").Visible = False
        
    End With
  '  st.Unprotect ("password123")
 
    ms.Protect ("password123")
  '  End If
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I did my own workaround where I made the Pivot table tab very hidden and then made a mirror tab with formulas of it and locked that down and moved the slicer over.
 
Upvote 0
I did my own workaround where I made the Pivot table tab very hidden and then made a mirror tab with formulas of it and locked that down and moved the slicer over.
Hi, just wondering if you've had any further luck with this one? I've a similar issue but because the pivot won't filter in new items on the row fields, the slicer won't update to show them or filter out 'blank'.
 
Upvote 0
Yes I did mate, I used this code, might be a bit of unncessary in it but does the job. The allowusing pivot tables true bit if the important part
VBA Code:
Sub Allowupdate()
Dim ms As Worksheet
 Dim xpt As PivotTable
Set ms = Sheets("Sheet1")
ms.Unprotect ("12345")
ActiveWorkbook.RefreshAll
With ActiveSheet
        .Protect UserInterFaceOnly:=True
        For Each xpt In .PivotTables
            xpt.RefreshTable
        Next xpt
    End With
ms.Protect ("12345"), AllowUsingPivotTables:=True

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top