Microsoft 365 Macro, dates et heures courantes

laplayast

XLDnaute Occasionnel
Bonjour,
j'ai créer 2 macros entrée et sortie correspondant à des dates et heures; comment les utiliser sur n'importe quelles cellules. Voir fichier joint

Merci pour l'aide.
 

Pièces jointes

  • Classeur2.xlsm
    21.3 KB · Affichages: 2
Solution
Remplacez le code actuel par celui-ci :

VB:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)

     If Target.Count > 1 Then Exit Sub
     
     If Not Intersect(Target, Columns("G")) Is Nothing And Target.Interior.Color = RGB(217, 217, 217) Then
        Target = Date
        Target.Offset(0, 1) = Format(Now(), "hh:mm:ss")
     End If
     
     If Not Intersect(Target, Columns("J")) Is Nothing And Target.Interior.Color = RGB(217, 217, 217) Then
        Target = Date
        Target.Offset(0, 2) = Format(Now(), "hh:mm:ss")
     End If
     
     Cancel = True

End Sub

Eric KERGRESSE

XLDnaute Occasionnel
Remplacez le code actuel par celui-ci :

VB:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)

     If Target.Count > 1 Then Exit Sub
     
     If Not Intersect(Target, Columns("G")) Is Nothing And Target.Interior.Color = RGB(217, 217, 217) Then
        Target = Date
        Target.Offset(0, 1) = Format(Now(), "hh:mm:ss")
     End If
     
     If Not Intersect(Target, Columns("J")) Is Nothing And Target.Interior.Color = RGB(217, 217, 217) Then
        Target = Date
        Target.Offset(0, 2) = Format(Now(), "hh:mm:ss")
     End If
     
     Cancel = True

End Sub
 

Discussions similaires

Réponses
9
Affichages
414

Statistiques des forums

Discussions
312 248
Messages
2 086 593
Membres
103 248
dernier inscrit
Happycat