Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim i As Byte, j, col, derlig As Long, repere, r As Range
repere = [{"Feuil1","compteur1","d";"Feuil2","compteur2","c"}]
With Application
For i = 1 To UBound(repere, 1)
j = .Match(Sh.Name, .Index(repere, i, 0), 0)
If IsNumeric(j) Then Exit For
Next
End With
If Sh.Name = repere(1, 1) Or Sh.Name = repere(2, 1) Then
On Error Resume Next
Set r = Intersect(Target, Columns(repere(i, j + 2)), Rows("3:" & Rows.Count))
On Error GoTo 0
If r Is Nothing Then Exit Sub
If r.Count > 1 Then Exit Sub
If r.Value = "" Then Exit Sub
Application.EnableEvents = False
With Sheets(repere(i, j + 1))
col = Application.Match(Cells(r.Row, 1).Value, .Rows(1), 0)
If Not IsError(col) Then
derlig = .Range("a" & Rows.Count).End(xlUp).Row + 1
If .Cells(derlig - 1, 1).Value = Date Then
If .Cells(derlig - 1, col).Value = "" Then
derlig = .Range("a" & Rows.Count).End(xlUp).Row
End If
End If
.Cells(derlig, 1).Value = Date
.Cells(derlig, col).Value = r.Value
End If
End With
Set r = Nothing
Application.EnableEvents = True
End If
End Sub