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 29 30 31 32 33 34 35 36 37
| Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim premiercellulelibre As Long
Dim Ancienvaleur As Variant, Nouvellevaleur As Variant
Dim rngNeuSel As Range
If Target.Count > 1 Then Exit Sub
If Sh.Name = "Protocol" Then Exit Sub
If Intersect(Target, Sh.Range("A2:L30")) Is Nothing Then Exit Sub
Application.EnableEvents = False
mois = Sh.Cells(1, Target.Column).Value
Nouvellevaleur = Target.Value
Set rngNeuSel = Selection
Application.Undo
Ancienvaleur = Target.Value
Target.Value = Nouvellevaleur
On Error Resume Next
rngNeuSel.Activate
On Error GoTo 0
With Sheets("Protocol")
premiercellulelibre = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Range(.Cells(premiercellulelibre, "A"), .Cells(premiercellulelibre, "H")).NumberFormat = "General"
.Cells(premiercellulelibre, 1) = Sh.Name
.Cells(premiercellulelibre, 2) = Environ("username")
.Cells(premiercellulelibre, 3).Value = Date
.Cells(premiercellulelibre, 4) = Time
.Cells(premiercellulelibre, 5) = Target.Address(0, 0)
.Cells(premiercellulelibre, 6) = Ancienvaleur
.Cells(premiercellulelibre, 7) = Target.Value
.Cells(premiercellulelibre, 8) = mois 'ici sera le mois
End With
Application.EnableEvents = True
End Sub |
Partager