1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| Private Sub ChangeDate(ColonneChanges As Long)
On Error GoTo gestionerreur
Dim j As String
Dim m As String
Dim a As String
Dim heure As String
Dim min As String
Dim sec As String
Dim i As Integer
Dim k As Integer
Dim MaDate As Date
Dim MonHeure As Date
Dim MonHeureT As String
Set f = Worksheets(1)
k = 2
While Cells(k, 1).Value <> ""
k = k + 1
Wend
For i = 2 To k - 1
If Cells(i, ColonneChanges).Value = "" Then
Cells(i, ColonneChanges).Value = ""
ElseIf Cells(i, ColonneChanges).NumberFormat = "General" Then
j = Left(Cells(i, ColonneChanges).Value, 2)
m = Mid(Cells(i, ColonneChanges).Value, 4, 2)
a = Mid(Cells(i, ColonneChanges).Value, 7, 4)
MaDate = DateSerial(a, m, j)
MonHeureT = Right(Cells(i, ColonneChanges).Value, 8)
heure = Left(MonHeureT, 2)
min = Mid(MonHeureT, 4, 2)
sec = Right(MonHeureT, 2)
MonHeure = TimeSerial(heure, min, sec)
Cells(i, ColonneChanges).Value = CDate(MaDate & " " & MonHeure)
Else
m = Left(Cells(i, ColonneChanges).Value, 2)
j = Mid(Cells(i, ColonneChanges).Value, 4, 2)
a = Mid(Cells(i, ColonneChanges).Value, 7, 4)
MaDate = DateSerial(a, m, j)
MonHeureT = Right(Cells(i, ColonneChanges).Value, 8)
heure = Left(MonHeureT, 2)
min = Mid(MonHeureT, 4, 2)
sec = Right(MonHeureT, 2)
MonHeure = TimeSerial(heure, min, sec)
Cells(i, ColonneChanges).Value = CDate(MaDate & " " & MonHeure)
End If
Cells(i, ColonneChanges).NumberFormat = "dd/mm/yyyy hh:mm"
Next i
Exit Sub
gestionerreur:
If Err.Number = 13 Then
Resume Next
End If
End Sub |
Partager