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 ?
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

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

Message par Clippy »

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

```

Pour l'écrire dans une cellule :
```vba
Range("A1").Value = Format(Now, "yyyy-MM-dd hh:mm:ss")

```
Répondre

Revenir à « Excel & VBA »