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
   | Private Sub Worksheet_Change(ByVal Target As Range)
 
    If Target.Column = 1 Then
    'Ecris la dâte actuelle dans la colonne G apres avoir scanner en colonne A
        Cells(Target.Row, 7).Value = Date
    End If
 
    If Target.Column = 4 Then
    'Ecris lheure actuelle dans la colonne D apres avoir scanner le START
        Cells(Target.Row, 4).Value = Time()
    End If
 
    If Target.Column = 5 Then
    'Ecris lheure actuelle dans la colonne E apres avoir scanner le END
        Cells(Target.Row, 5).Value = Time()
    End If
 
    If Not Application.Intersect(Target, Range("E:E")) Is Nothing Then
    'Permet la soustraction des heures du debut et de fin
        Target.Offset(0, 1) = Format(Target.Offset(0, -1).Value - Target.Value, "hh:mm:ss")
    End If
 
    If Not Intersect(Target, Range("A:D")) Is Nothing Then
 
             If Target.Column = 1 Then
             'Permet de passer a la cellule suivante (TAB) dans la colonne A
                 Target.Offset(0, 1).Select
             End If
    End If
 
    If Target.Column = 4 Then '-->>> Colonne B mais à adapter !
    If Range("A1") = "" Then '-->>> Car .Find commence la recherche par défaut après la 1ère cellule de la colonne
        Range("A1").Select
    Else
        Columns(1).Find(What:="", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlNext).Select
    End If
    End If
 
    Dim Lig As Long
        If Not Intersect(Target, Columns("E:E")) Is Nothing Then
        Lig = 1
            Do While Not IsEmpty(Range("A" & Lig))
            Lig = Lig + 1
    Loop
    Range("A" & Lig).Select
    End If
 
End Sub | 
Partager