Private Sub CommandButton1_Click()
If ListUtilisateur = "" Then
MsgBox "Veuillez vous identifier", vbInformation
End If
If ListUtilisateur.Value = "Production" Then
If MDP.Value <> "prod" Then
MsgBox "mauvais mot de passe", vbCritical
Else
With Sheets("Relevé")
.Unprotect Password:="toto"
' Déprotéger la partie Production
ProtectionProd (False)
' Protéger la partie Maintenance
ProtectionMain (True)
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="toto"
End With
End If
End If
If ListUtilisateur.Value = "Maintenance" Then
If MDP.Value <> "maint" Then
MsgBox "mauvais mot de passe", vbCritical
Else
With Sheets("Relevé")
.Unprotect Password:="toto"
' Protéger la partie Production
ProtectionProd (True)
' Déprotéger la partie Maintenance
ProtectionMain (False)
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="toto"
End With
With Feuil3
Range("D1").Value = ListUtilisateur.Value
Range("D2").Value = MDP.Value
End With
End If
End If
' Fermet l'USF
Unload Me
End Sub
Private Sub CommandButton3_Click()
UserForm2.Show
End Sub
Private Sub UserForm_Initialize()
With Feuil3
ListUtilisateur.List = .Range("A1:A" & .Range("A65536").End(xlUp).Row).Value
End With
End Sub
'Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) 'inactive la croix
'If CloseMode = 0 Then Cancel = True
'End Sub
' Enlève ou met la protection suivant l'activité
Sub ProtectionProd(Flg As Boolean)
With Sheets("Relevé")
.Range("B5:G" & Rows.Count).Locked = Flg
.Range("K5:K" & Rows.Count).Locked = Flg
.Range("N5:N" & Rows.Count).Locked = Flg
.Range("R5:R" & Rows.Count).Locked = Flg
End With
End Sub
Sub ProtectionMain(Flg As Boolean)
With Sheets("Relevé")
.Range("J5:J" & Rows.Count).Locked = Flg
.Range("L5:M" & Rows.Count).Locked = Flg
.Range("Q5:Q" & Rows.Count).Locked = Flg
End With
End Sub