Date & Time Format
You may want to format the cells in an unambiguous format.
I like: mmmm dd, yyyy hh:mm:ss
Then check to see if the converted values actually represent the dates from the
original source.
I'm wondering if 01.02.2008 12:30
is being converted to: January 2, 2008 12:30
or if it's getting converted to: February 1, 2008 12:30
Sometimes, just because the results look like dates doesn't mean that they are
the correct dates.
Brampton76 wrote:
And finally....... If I format the cells as dd/mm/yyyy hh:mm and run your
routine I get mm/dd/yyyy hh:mm. However, If I alter your routine to replace
as dd/mmm/yyyy hh:mm I get dd/mm/yyyy hh:mm - all a bit odd, but I am where I
need to be. Again, many thanks for your help and guidance.
--
Glenn
"Roger Govier" wrote:
Hi Glenn
The following seemed to work for me
Sub test()
Dim c As Range
For Each c In Range("G2:G13")
c.Value = Format(Replace(c, ".", "/"), "dd/mm/yyyy hh:mm")
Next
End Sub
--
Regards
Roger Govier
"Brampton76" wrote in message
...
I export data that includes the date & time. The data is exported
directly
into Excel with the date & time as follows: dd.mm.yyy hh:mm. This
presents
no great problem because a simple find & replace on the column gives me
dd/mm/yyyy hh:mm which Excel recognises as a date and my formulas work OK.
I
thought a Macro would save me some time, however, no amount of trying
prevents the Macro from formating the date mm/dd/yyyy hh:mm. I think I
have
tried all the formatting options (including checking the system date and
time) and even tried including the formatting in the Macro and editing the
date in VBE. But............. it will insist on giving me the month, day
and
year in that order. I thought it may be Excel 2000 (at work) but it also
happens in Excel 2003 (at home). Has anyone any thoughts please?
--
Glenn
--
Dave Peterson
|