helix123
09-30-2012, 07:07 PM
Hi,
What I would like to have is a stopwatch in excel which just displays minutes i.e. instead of 1 hour 30 min I want a macro to just show 90.
On a different forum I was able to find the following macro:
Dim SchedRecalc As Date, datStartTime As Date
Sub RecalcTimer()
Dim wbk As Workbook
Dim ws As Worksheet
Set wbk = ThisWorkbook
Set ws = wbk.Sheets(1) ' <== Change the "1" to appropriate #
'ws.Range("C3").Value = Format(Now, "dd-mmm-yy")
ws.Range("C4").Value = Format(Now - datStartTime, "hh:mm:ss")
Call SetTimer
End Sub
Sub SetTimer()
If datStartTime = 0 Then datStartTime = Now
SchedRecalc = Now + TimeValue("00:00:01")
Application.OnTime SchedRecalc, "RecalcTimer"
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=SchedRecalc, _
Procedure:="RecalcTimer", _
Schedule:=False
End Sub
Sub ResetTimer()
datStartTime = 0
End Sub
See attached spreadsheet which shows the buttons.
The first problem is that it shows it in the hours minutes seconds format. Is there a way to get to just show the number of minutes which have past?
Also if the timer is started and then stopped it seems that when the timer is restarted again it starts from excel's now time rather than the time at which the clock was initially.
Any help on this would be much appreciated.
Daniel
What I would like to have is a stopwatch in excel which just displays minutes i.e. instead of 1 hour 30 min I want a macro to just show 90.
On a different forum I was able to find the following macro:
Dim SchedRecalc As Date, datStartTime As Date
Sub RecalcTimer()
Dim wbk As Workbook
Dim ws As Worksheet
Set wbk = ThisWorkbook
Set ws = wbk.Sheets(1) ' <== Change the "1" to appropriate #
'ws.Range("C3").Value = Format(Now, "dd-mmm-yy")
ws.Range("C4").Value = Format(Now - datStartTime, "hh:mm:ss")
Call SetTimer
End Sub
Sub SetTimer()
If datStartTime = 0 Then datStartTime = Now
SchedRecalc = Now + TimeValue("00:00:01")
Application.OnTime SchedRecalc, "RecalcTimer"
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=SchedRecalc, _
Procedure:="RecalcTimer", _
Schedule:=False
End Sub
Sub ResetTimer()
datStartTime = 0
End Sub
See attached spreadsheet which shows the buttons.
The first problem is that it shows it in the hours minutes seconds format. Is there a way to get to just show the number of minutes which have past?
Also if the timer is started and then stopped it seems that when the timer is restarted again it starts from excel's now time rather than the time at which the clock was initially.
Any help on this would be much appreciated.
Daniel