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
| Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column <= 3 Then 'si la cellule sélectionnée est en colonne A ou B, sinon on sort du programme
If Cells(Target.Row, "A") <> "" And Cells(Target.Row, "K") <> "" Then 'Si A et K ne sont pas vides
If Cells(Target.Row, "AA") = "Maj" Then 'Si sur la même ligne en colonne AA, la Maj a déjà été faite
If MsgBox("Ce contact a dèjà été modifié, voulez-vous le modifier une nouvelle fois?", vbYesNo) = vbYes Then 'Demande d'autorisation d'une nouvelle modification
Application.EnableEvents = True 'Si la réponse est "oui", on accepte la modification
Exit Sub
Else
Application.Undo 'si la réponse est "non", on restitue la donnée d'origine
Application.EnableEvents = True
Exit Sub
End If
End If
If MsgBox("Ce contact doit-il être supprimé des données ?", vbYesNo) = vbYes Then
If MsgBox("Confirmez-vous la suppression de ce contact?", vbYesNo) = vbYes Then
Call CfnMsgBox
Application.EnableEvents = True
Exit Sub
End If
Else
Cells(Target.Row, "AA") = "Maj" 'ceci empêchera toutes nouvelles modifications sans accord
End If
End If
End If
Cells(Target.Row, "A").Select
Application.EnableEvents = True
End Sub |
Partager