XL 2010 Erreur avec ma boite de dialogue

ychc

XLDnaute Occasionnel
Bonjour à tous,

Je cherche a solutionner une erreur sur un petit bout de programme.
Je joint le fichier, tout y est expliqué.
C'est juste que je n'arrive pas à m'en sortir avec la condition "non" d'une boite de dialogue.
Merci à tous ceux qui pourront m'aider.
 

Pièces jointes

  • test protect 5- Copie.xls
    36 KB · Affichages: 28

Florian53

XLDnaute Impliqué
Salut,

essaye ceci:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If test = True Then Exit Sub
If Selection.Cells.Count > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub

If Application.Intersect(Target, Range("A1:A12")) Is Nothing Then Exit Sub
test = True
If MsgBox("une fois validé, impossible a modifier ?", vbYesNo, "Attention !") = vbYes Then
    ActiveSheet.Unprotect
    Target.Locked = True
  
Else
    Target.Select
    Target.ClearContents
End If
test = False


If Target.Column = 1 Then
ActiveSheet.Unprotect
    Target.Offset(0, 2) = Time
   
   ActiveSheet.Protect
    End If
End Sub
 

ychc

XLDnaute Occasionnel
Merci Florian,

Il suffit que je post, pour ensuite trouvé une solution qui fonctionne.
J'ai tout de suite voulu partager, ou supprimer mon post, que tu me trouvais
déja une solution.
Merci à tous et a ce super forum.


Code:
Private test As Boolean
Private Sub Worksheet_Change(ByVal Target As Range)

If test = True Then Exit Sub
If Selection.Cells.Count > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub

If Application.Intersect(Target, Range("A1:A12")) Is Nothing Then Exit Sub
test = True
If MsgBox("une fois validé, impossible a modifier ?", vbYesNo, "Attention !") = vbYes Then
    ActiveSheet.Unprotect
    Target.Locked = True
   
    Target.Offset(0, 2) = Time
Else
    Target.Select
    Target.ClearContents
End If
test = False
   ActiveSheet.Protect

End Sub
 

Discussions similaires

Réponses
17
Affichages
403

Statistiques des forums

Discussions
311 722
Messages
2 081 930
Membres
101 843
dernier inscrit
Thaly