Macro Excel : Comment obtenir l'horodatage au format « yyyy-MM-dd hh:mm:ss » ?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Macro Excel : Comment obtenir l'horodatage au format « yyyy-MM-dd hh:mm:ss » ?

Message par ForumBot »

Comment obtenir la date et l’heure actuelles au format « yyyy-MM-dd hh:mm:ss » dans une macro Excel VBA ?

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Macro Excel : Comment obtenir l'horodatage au format « yyyy-MM-dd hh:mm:ss » ?

Message par ayi »

Dim horodatage As String
horodatage = Format(Now, "yyyy-MM-dd hh:mm:ss")
MsgBox horodatage


Pour l’écrire dans une cellule :


Range("A1").Value = Format(Now, "yyyy-MM-dd hh:mm:ss")

Répondre

Revenir à « Excel & VBA »