Microsoft 365 format de cellules

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour à toutes et à tous,

Pour des besoins d'affichage, j'ai fait un ch'ti code qui semble fonctionner.
Je me permets de vous solliciter :
1- mon code vous parait-il être correct ?
2 - est-il possible de faire plus simple ?

Un grand merci à vous toutes et tous :)
Je joins le fichier test,
Je vous souhaite une bonne journée,
Amicalement,
lionel,
 

Pièces jointes

  • date_format.xlsm
    25.8 KB · Affichages: 4

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour JM,
Voilà ci-dessous :
Code:
Sub format_E5()
    Range([e7], Cells(Rows.Count, "e").End(xlUp)).ClearFormats
    Range([e7], Cells(Rows.Count, "e").End(xlUp)).NumberFormat = "dd mm yy hh:mm"
    Range([e7], Cells(Rows.Count, "e").End(xlUp)).HorizontalAlignment = xlCenter
    Range([e7], Cells(Rows.Count, "e").End(xlUp)).VerticalAlignment = xlCenter
    Range([e7], Cells(Rows.Count, "e").End(xlUp)).WrapText = True
End Sub
lionel :)
 

Staple1600

XLDnaute Barbatruc
Re

Ce n'est pas une blague
endives (chez moi) = With... End With

Sinon à la sauce Staple (spécial confinement) ;)
VB:
Sub format_E5_b()
Dim r As Range: Set r = Range([E7], Cells(Rows.Count, "E").End(3))
r.ClearFormats: r.NumberFormat = "dd mm yy hh:mm": r.HorizontalAlignment = 3: r.VerticalAlignment = xlCenter: r.WrapText = -1
End Sub
 

Staple1600

XLDnaute Barbatruc
Re

Tu comprends mieux ainsi ?
Enrichi (BBcode):
Sub format_E5()
With Range([e7], Cells(Rows.Count, "e").End(xlUp))
   .ClearFormats
   .NumberFormat = "dd mm yy hh:mm"
   .HorizontalAlignment = xlCenter
   .VerticalAlignment = xlCenter
   .WrapText = True
End With
End Sub
Vu la proximité phonétique entre endives et End With, souvent dans mes posts, je parle de: ajouter des endives ;)
Capito ? ;)
 

Discussions similaires

Statistiques des forums

Discussions
313 077
Messages
2 095 073
Membres
106 166
dernier inscrit
anesalis