Hi:
I have text file, I open it in excel 2003. Column A has date (format: 20/06/2014 11:00:00 AM). I wan to change this date & time format to: mm/dd/yyyy hh:mm:ss. I save it in as text file and import data into other program which only reads date format (mm/dd/yyyy hh:mm:ss). Surfing internet with solution but can not make it working.
Here is what I got so far:
1. Range("A2").Value = Format(Range("A2").Value, "mm/dd/yyyy hh:mm:ss")
this gives me only: 6/20/2014 11:00 and missing ss part(seconds). plus it only work for a cell not for range (if I change it to Range ("A:A") then give me error.
2. then I have following code:
im rngCell As Range
Range("A:A").Select
For Each rngCell In Selection
If IsDate(rngCell.Value) Then
rngCell.Value = Format(rngCell.Value, "mm/dd/yyyy") & Format(rngCell.Value, "hh:mm:ss")
End If
Next rngCell
It works fine but does not put space between date and time. If I try rngCell.Value = Format(rngCell.Value, "mm/dd/yyyy") & " " & Format(rngCell.Value, "hh:mm:ss"), it works but skips last :00 part (seconds) from time part.
Any solution will be appreciate.
Thanks,
Ria
I have text file, I open it in excel 2003. Column A has date (format: 20/06/2014 11:00:00 AM). I wan to change this date & time format to: mm/dd/yyyy hh:mm:ss. I save it in as text file and import data into other program which only reads date format (mm/dd/yyyy hh:mm:ss). Surfing internet with solution but can not make it working.
Here is what I got so far:
1. Range("A2").Value = Format(Range("A2").Value, "mm/dd/yyyy hh:mm:ss")
this gives me only: 6/20/2014 11:00 and missing ss part(seconds). plus it only work for a cell not for range (if I change it to Range ("A:A") then give me error.
2. then I have following code:
im rngCell As Range
Range("A:A").Select
For Each rngCell In Selection
If IsDate(rngCell.Value) Then
rngCell.Value = Format(rngCell.Value, "mm/dd/yyyy") & Format(rngCell.Value, "hh:mm:ss")
End If
Next rngCell
It works fine but does not put space between date and time. If I try rngCell.Value = Format(rngCell.Value, "mm/dd/yyyy") & " " & Format(rngCell.Value, "hh:mm:ss"), it works but skips last :00 part (seconds) from time part.
Any solution will be appreciate.
Thanks,
Ria