elapsed minutes

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
.
Barry was describing the format of the time ...

Are you now requesting code to make the time update in real time ? Or perhaps, calculating the difference between two times ?
 
Upvote 0
Yes that is right, both actually. Thank you very much.
 
Upvote 0
Just want to add this. I want to subtract 2:00am from 10:00pm

Starting time 10:00 pm
end time: 2:00 am

so total number of hours is 4. How can I subtract 2:00 am - 10:00 pm. Do I need to format the result cells as [hh]:mm first? It did not work? Thanks
 
Last edited:
Upvote 0
.
When you are working with times that go past midnight, the best approach (and easiest for me at least) is to include the date with the times. Excel then
can determine you are speaking of times spanning two days. You can format the cell where the answer will be displayed to show only the hours/minutes.

As for a timer, here is a basic project :

Code:
Option Explicit


Dim SchedRecalc As Date


Sub Recalc()


With Sheet1.Range("H3")


.Value = Format(Now, "mm/dd/yyyy - hh:mm:ss AM/PM")


End With


Call SetTime


End Sub


Sub SetTime()


SchedRecalc = Now() + TimeValue("00:00:01")


Application.OnTime SchedRecalc, "Recalc"


End Sub


Sub Disable()


On Error Resume Next


Application.OnTime EarliestTime:=SchedRecalc, Procedure:="Recalc", Schedule:=False


End Sub


Sub clr()


Disable


Sheet1.Range("H3").Value = " "


End Sub

Place a 3 commandbuttons on the worksheet. One titled START ... one titled STOP ... and one titled CLEAR.

Have the START button connected to the macro : SET TIME

Have the STOP button connected to the macro : DISABLE

Have the CLEAR button connected to the macro : CLR

The macro is coded to display the date/time in H3.
 
Upvote 0
That is a nice project. I will spend time to understand it. Thank you so much. I appreciate it.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top