Bonjour,s'ils vous plaît je veux ajouter une rubrique qui me donne la date et l'heure quand je rentre une voiture
Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A1000")) Is Nothing Then
If Cells(Target.Row, "B") = "" Then Cells(Target.Row, "B") = Now
End If
End Sub
Où je vais rentrer se code?Bonjour Tachouha, Jacky,
Un essai en PJ.
Quand on entre une voiture en colonne A, cela met automatiquement date et heure en colonne B, avec :
VB:Sub Worksheet_Change(ByVal Target As Range) If Target.Count > 1 Then Exit Sub If Not Intersect(Target, Range("A1:A1000")) Is Nothing Then If Cells(Target.Row, "B") = "" Then Cells(Target.Row, "B") = Now End If End Sub
ReRe,
Le code est déjà dans la PJ :
Regarde la pièce jointe 1158735
Avez vous validé les macros lorsqu'XL vous le demande ?
Sinon vérifier dans Options Excel/Centre de gestion ... /Paramètres.../Paramètres des macros si ce n'est pas la première option qui est choisie car dans ce cas il n'y a pas de notification. Cochez alors la seconde "toutes les macros avec notification" :
Regarde la pièce jointe 1158736
et dans ce cas XL vous posera la question :
Regarde la pièce jointe 1158737
Vous avez un XL piraté, je ne sais pas comment il réagit :
Regarde la pièce jointe 1158741
Vous pouvez essayez de choisir la 4eme option pour voir :
Regarde la pièce jointe 1158742
Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A1000")) Is Nothing Then
If Cells(Target.Row, "B") = "" Then Cells(Target.Row, "B") = Now
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("C1:C1000")) Is Nothing Then
If Cells(Target.Row, "A") <> "" Then
Target = Now
Cells(Target.Row, "D") = Now - Cells(Target.Row, "B")
End If
End If
End Sub