Dear All,
I receive data in different date formats( dd/mm/yyyy hh:mm:ss, dd-mm-yyyy hh:mm:ss.....etc date, text mixed formats). I want final output should be in mm/dd/yyyy hh:mm:ss
Below macro (not written by me) only does part of the job. I have attached the excel file. Column B highlighted in red is not converted as expected. I want date to be converted as in column C (i.e: mm/dd/yyyy hh:mm:ss)
Sub a1105914a()
Dim va, x
Dim i As Long, c As Range, z As String
With Range("A5", Cells(Rows.Count, "A").End(xlUp))
va = .Value
For i = 1 To UBound(va, 1)
x = va(i, 1)
z = CStr(Format(x, "Short Time"))
If Left(x, 2) < 13 Then
va(i, 1) = Format(DateSerial(Year(x), Day(x), Month(x)), "dd-mm-yy") & " " & z
Else
va(i, 1) = CDate(x)
End If
Next
.Value = va
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
.HorizontalAlignment = xlRight
End With
End Sub
PC time format is mm/dd/yyyy
Please any one help me,
Bookmarks