PPRuNe Forums - View Single Post - Excel - Elapsed Time - Calc.
View Single Post
Old 19th February 2003 | 01:30
  #6 (permalink)  
Agent86
Guest
 
Posts: n/a
Post

If you are familiar with visual basic or modifying macros try this

Add this code to a module in the workbook

Function Timediff(startT, EndT)
Dim timediff1
timediff1 = DateDiff("n", startT, EndT)
If startT > EndT Then timediff1 = timediff1 + 1440
Timediff = TimeSerial(Int(timediff1 / 60), timediff1 Mod 60, 0)
End Function

then in the sheet where you want the calc to take place use the function Timediff

ie if start time is in cell D3 and end time is is cell D4 and you want the time difference to display in cell D5, type

=Timediff(D3,D4) into cell D5

You will need to format cell D5 to the time format for it to display correctly.

for info the "n" in the Datediff function is for Minutes and 1440 is obviously the number of minutes in a day.

PM me if you need help in adding a module as I don't know your experience level in VB and don't want to tell you how to suck eggs.

MAx