Calculating Elapsed time in a macro

  • Thread starter Thread starter Art D.
  • Start date Start date
A

Art D.

I have a data stream that is providing time in military format (hh:mm:ss)in
column A begining at row 12, and I want to place elapsed time in column B.
I've been subtracting the values of the cells using A12 as the reference
value, but I'm getting just 0.0

Macro section as follows:
it = Sheets("Data").Cells(12,1).value
at = Sheets("Data").Cells(RowPointer, 1).value
et = at - it
Sheets("Data").Cells(RowPointer,2).Formula = et

(it = initial time, at = actual time, et = elapsed time)

Data would look like:

12:12:00
12:12:30
12:13:00
12:13:30

I need to get
0:00
0:30
1:00
1:30
into the second column, but doing the calculation in the macro, not in the
sheet.

Help! I'm stumped, using Excel 2000 right now.
thanks
Art
 
Sub AAAAA()
For rowPointer = 13 To 15
With Sheets("Data")
it = .Cells(12, 1).Value
at = .Cells(rowPointer, 1).Value
et = at - it
..Cells(rowPointer, 2).Value = et
..Cells(rowPointer, 2).NumberFormat = "hh:mm:ss"
End With
Next
End Sub

Worked for me.
 
Back
Top