Re : VBA- probleme pour afficher l'heure au bon format
Re bonjour a tous,
Merci à vous pour le temps passé sur mon problème mais je n'ai pas été assez clair la première fois. voici ce que je veux essayer de faire.
@Modeste geedee : le principe est bon quand je fais le test à la main, pas pas quand je l'automatise par une macro. Je dois avoir un problème de format anglais/français
@Robert : ta macro fonctionne visuellement mais que tu cliques sur une cellule je vois la date et l'heure apparaitre. Je ne peux pas exploiter cette manière dans un tableau croisé dynamique.
@Paf : voici le code utilisé pour la colonne D :
Sub test()
Dim NbLignes As Integer
Dim f As Worksheet
Set f = ActiveSheet 'selectionne ta feuille active
NbLignes = f.UsedRange.Rows.Count
' Génération colonnes "Date Ouverture Incident" et "Heure Ouverture Incident"
Columns("E:E").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("E1").Select
ActiveCell.FormulaR1C1 = "Date Ouverture Incident"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Heure Ouverture Incident"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=DATEVALUE(DAY(LEFT(RC[-1],10))&""/""&MONTH(LEFT(RC[-1],10))&""/""&YEAR(LEFT(RC[-1],10)))"
Range("F2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RIGHT(RC[-2],8),8)"
Selection.AutoFill Destination:=Range("F2:F" & NbLignes), Type:=xlFillDefault
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E" & NbLignes), Type:=xlFillDefault
Columns("E:E").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("F:F").Select
Selection.Copy
Columns("E:E").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("G:G").Select
Application.CutCopyMode = False
Selection.Copy
Columns("F:F").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("G:G").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Columns("D
").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Columns("D
").Select
Selection.NumberFormat = "m/d/yyyy"
Columns("E:E").Select
Selection.NumberFormat = "hh:mm:ss"
end sub
Merci par avance pour votre aide.