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

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

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

Message par Clippy »

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 : 9242
Inscription : mer. 22 avr. 2026, 17:21

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 »