1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Option Explicit
'Option Private Module
Public Sub Not_Restrictions()
'Ctrl + Shift + X
Dim response
Do
response = Application.InputBox("Mot de passe :", Type:=2, Title:="Oter la Protection")
Loop While response <> PWD And response = ""
If response = False Then Exit Sub
With Worksheets("User 1")
.Unprotect Password:=PWD
For Each pt In .PivotTables
pt.EnableFieldList = True
Next
End With
'ActiveWorkbook.ShowPivotTableFieldList = True
End Sub
Public Sub Restrictions()
'Ctrl + Shift + W
With Worksheets("User 1")
For Each pt In .PivotTables
pt.EnableFieldList = False
Next
.Protect Password:=PWD, _
userinterfaceonly:=True, _
AllowUsingPivotTables:=True
End With
'ActiveWorkbook.ShowPivotTableFieldList = False
End Sub |