ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calculating Elapsed time in a macro (https://www.excelbanter.com/excel-programming/281103-calculating-elapsed-time-macro.html)

Art D.

Calculating Elapsed time in a macro
 
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



Tom Ogilvy

Calculating Elapsed time in a macro
 
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.

--
Regards,
Tom Ogilvy



Art D. wrote in message
...
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






All times are GMT +1. The time now is 06:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com