trouble with subtracting elapsed times
Joel's answer does not work in xl2007 or xl2002 either. Returns following
error.
Complile error:
Type-declaration character does not match decalred data.
Did you run the test that I posted? The problem is all with VBA's display of
the date/time. The correct underlying value is there. Trust me!!!!! (Just for
the record all code and answers that I post are tested unless I specifically
say it is untested.)
Modifying Joel's answer, the following will work and return the correct
double precision number.
Sub test()
Dim time1 As Date
Dim start As Date
Dim timeDiff As Double
Dim time1Double As Double
'Date and time in Range("B6")
'is 06 Aug 2009 09:35:24 PM
start = Sheets("Timing Sheet").Range("B6")
time1 = Now() - start
time1Double = time1
timeDiff = Now - start
MsgBox WorksheetFunction.Text(time1, "[hh]:mm:ss")
MsgBox WorksheetFunction.Text(time1, "00.000000")
Stop
End Sub
--
Regards,
OssieMac
|