Private Sub ToggleButton1_Click()
Dim MdP As String
If ToggleButton1 = True Then
ToggleButton1.Interior.ColorIndex = 3
For sh = 1 To ActiveWorkbook.Sheets.Count
Sheets(sh).Protect "alain"
ToggleButton1.BackColor = &HFF&
ToggleButton1.Caption = "Déprotection"
Next
Else
MdP = InputBox("Mot de passe ?", "Déblocage de la feuille")
If MdP = "alain" Then
For sh = 1 To ActiveWorkbook.Sheets.Count
Sheets("Feuil1").Unprotect "alain"
ToggleButton1.BackColor = &HFF00&
ToggleButton1.Caption = "Protection"
Next
End If
End If
End Sub
Private Sub ToggleButton1_Click()
Dim MdP As String
Dim X As Byte
For X = 1 To ActiveWorkbook.Worksheets.Count
If ToggleButton1 = True Then
ToggleButton1.Interior.ColorIndex = 3
Sheets(X).Protect "alain"
ToggleButton1.BackColor = &HFF&
ToggleButton1.Caption = "Déprotection"
Else
MdP = InputBox("Mot de passe ?", "Déblocage de la feuille")
If MdP = "alain" Then
Sheets(X).Unprotect "alain"
ToggleButton1.BackColor = &HFF00&
ToggleButton1.Caption = "Protection"
End If
End If
Next
End Sub
Apparemment, dans la macro de JCGL, il faut saisir le mot de passe autant de fois qu'il y a de feuilles , dans la macro de Papou-net, le déblocage ne s'effectue pas sur la totalité des feuilles et dans la macro de CBernard T, ça marche !
Dois-je faire un MIX ?