Bonjour,
Sous Excel (Microsoft 365, Version 2306, Build 16529) et W10, le code suivant fonctionnait .... il y a de nombreux utilisateurs, possible qu'un de ceux-ci aurait altéré le code. Un mot rapide d'explication : 1) Première partie permet d'activer le suivi 2) La seconde partie copie les changements dans une feuille nommée "log". J'ai un doute sur la ligne "Set lo = Worksheets("log").Range("LogData").ListObject". Comment vérifier que LogData est bien défini ? De ce que j'ai pu tracer, la condition suivante est validée : ".InsertRowRange Is Nothing"
Merci pour vos conseils et aides,
Cordialement,
Option Explicit
Dim PreviousValue, bln As Boolean, LogEnable As Boolean
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
LogEnable = Cells(2, 5)
If LogEnable Then
If Target.CountLarge > 1 Then
MsgBox "Please select a single cell !...", 64, "Information"
bln = False
Else
PreviousValue = Target.Value
bln = True
End If
Else
bln = False
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lo As ListObject, rCell As Range, arr(7)
If bln = True Then
If Target.Value <> PreviousValue Then
Set lo = Worksheets("log").Range("LogData").ListObject
With lo
If .InsertRowRange Is Nothing Then
Set rCell = .HeaderRowRange.Cells(1).Offset(.ListRows.Count + 1)
Else
Set rCell = .InsertRowRange.Cells(1)
End If
End With
arr(0) = ActiveSheet.Name
arr(1) = Cells(Target.Row, 3)
arr(2) = Format(Now(), "dd/mm/yyyy, hh:mm:ss")
arr(3) = Application.UserName
arr(4) = Cells(1, Target.Column)
arr(5) = Target.Address
arr(6) = PreviousValue
arr(7) = Target.Value
rCell.Resize(, 8) = arr
End If
End If
End Sub
Edit modo : Mis code entre balises