View Single Post
  #1   Report Post  
scw-tzg
 
Posts: n/a
Default formatting date-time values in macro

Using excel 2003.

Have column with date-time values. I have column formatting: "m/d/yyyy
hh:mm:ss.000". Typical column displays "1/1/3018 00:12:03.930" in the cell
and displays "1/1/3018 12:12:04 AM" in formula bar.

When I try to get the formatted value for the cell in a macro using this
code:
Format(Worksheets("Sheet1").Cells(llCurrentRow, 14).Value, "m/d/yyyy
hh:mm:ss.000") I'm getting "1/1/3018 00:12:04.000" as my result. If I change
my macro code to use format "m/d/yyyy hh:mm:ss.sss" then I get "1/1/3018
00:12:04.044" for my result. But what I really want is the value I see
looking at the spreadsheet cell "1/1/3018 00:12:03.930".

Alternatively, I've tried to copy the cell's formatted value to another
cell, but I haven't figured out how to do that either.

Any help appreciated. TIA.

Susan