View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.misc
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default How to I subtract two dates & times to obtain a time

"msbutton27" wrote:
I am opening a TEXT file that contains 2 columns, and 900 rows.
[....]
the only way I see to do this is to enter them
in manually all over - is there a better way?


I don't know of a way to do this directly at import time, nor with an Excel
command after importing.

If no one offers a suggestion along those lines, perhaps the following macro
will be useful.

First, make a copy of the Excel file or worksheet, since the effects of the
macro cannot be undone.

Then select the cells in the 900 rows, then execute the macro:

Sub doit()
Dim cell As Range
For Each cell In Selection
cell = Left(cell, Len(cell) - 11) & "," & Right(cell, 11)
cell.NumberFormat = "mmm dd yyyy hh:mm"
Next cell
End Sub


----- original message -----

"msbutton27" wrote in message
...
I actually think I know what is going on.

I am opening a TEXT file that contains 2 columns, and 900 rows. So when I
convert it from text to excel for some reason Column A or B are changing
to
the correct format, it is getting picked up as TEXT. I can format the
columns
manually and it has no affect, the only way I see to do this is to enter
them
in manually all over - is there a better way?

...Mike

"Eduardo" wrote:

Hi,
use

=+RIGHT(B3,5)-RIGHT(A3,5)

and then format column c as

h:mm

hope this helps

"msbutton27" wrote:


Thanks but the [t]:mm would produce and error when trying to implement.