Proteger feuille

Bonjour le forum,

Sur ce code :

Sub Macro9()
Dim password As String
password = "1234"
    ActiveSheet.Unprotect password
    ActiveSheet.PivotTables("Tableau croisé dynamique2").PivotCache.Refresh
    ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
        True, AllowUsingPivotTables:=True
End Sub

Savez vous ou je dois mettre le password pour protéger ma feuille avec un mots de passe? j'ai essayer presque partout mais j'ai toujours une erreur de syntaxe.

Merci pour votre aide.

J'ai finalement trouver après plusieurs test :

Sub Macro9()
Dim password As String
password = "1234"
    ActiveSheet.Unprotect password
    ActiveSheet.PivotTables("Tableau croisé dynamique2").PivotCache.Refresh
    ActiveSheet.Protect password, DrawingObjects:=False, Contents:=True, Scenarios:= _
        True, AllowUsingPivotTables:=True
End Sub
Rechercher des sujets similaires à "proteger feuille"