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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim premiercellulelibre As Long
Dim Ancienvaleur As Variant, Nouvellevaleur As Variant
Dim mois As Variant
Dim Date_Jours As Variant
Dim What As Variant
Dim Origine As Object
Dim Destination As Object
If Target.Count > 1 Then Exit Sub
If Sh.Name = "Protocol" Then Exit Sub
If Intersect(Target, Sh.Range("A7:M35")) Is Nothing Then Exit Sub
Set Origine = Target
Application.EnableEvents = False
Nouvellevaleur = Origine.Value
Application.Undo
Ancienvaleur = Origine.Value
Origine.Value = Nouvellevaleur
With Sheets("Protocol")
premiercellulelibre = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
What = Sh.Name
Set Destination = .Cells(premiercellulelibre, "A")
Call transfererVersCelluleDestination(What, Destination)
What = Environ("username")
Set Destination = .Cells(premiercellulelibre, 2)
Call transfererVersCelluleDestination(What, Destination)
What = Date
Set Destination = .Cells(premiercellulelibre, 3)
Call transfererVersCelluleDestination(What, Destination)
What = Time
Set Destination = .Cells(premiercellulelibre, 4)
Call transfererVersCelluleDestination(What, Destination)
What = Origine.Address(0, 0)
Set Destination = .Cells(premiercellulelibre, 5)
Call transfererVersCelluleDestination(What, Destination)
What = Ancienvaleur
Set Destination = .Cells(premiercellulelibre, 6)
Call transfererVersCelluleDestination(What, Destination)
What = Origine.Value
Set Destination = .Cells(premiercellulelibre, 7)
Call transfererVersCelluleDestination(What, Destination)
mois = Sh.Cells(6, Origine.Column).Value
What = mois
Set Destination = .Cells(premiercellulelibre, 8)
Call transfererVersCelluleDestination(What, Destination)
Date_Jours = Sh.Cells(Origine.Row, 1).Value
What = Date_Jours
Set Destination = .Cells(premiercellulelibre, 9)
Call transfererVersCelluleDestination(What, Destination)
End With
Application.EnableEvents = True
End Sub
Sub transfererVersCelluleDestination(What, Destination)
If TypeName(What) = "String" Then
Destination.NumberFormat = "@"
Else
Destination.NumberFormat = "General"
End If
Destination.Value = What
End Sub |