I am working in a office where I need to keep track of few things to count time. I can't go and stand there all the time. So, I need a program where I can keep track of different things. I have found some codes but I really don't know what & how to utilize it.
this run the clock with micro seconds:
======================================
Code:Private TimerCell As Range Private TimerEnabled As Boolean Private TimerValue As Double Sub SetTimerCell() Set TimerCell = Worksheets("Sheet1").Range("M2") TimerCell.NumberFormat = "@" End Sub Sub StartTimer() If TimerEnabled Then Exit Sub If TimerCell Is Nothing Then SetTimerCell TimerEnabled = True ShowTime End Sub Sub StopTimer() TimerEnabled = False End Sub Sub ResetTimer() TimerEnabled = False If TimerCell Is Nothing Then SetTimerCell TimerValue = 600 TimerCell = "10:00.0" End Sub Sub ShowTime() Dim Delay As Single Dim Mins As Integer Dim Secs As Variant Dim StartTime As Single Delay = 0.1 StartTime = Timer Do While TimerEnabled While Timer < StartTime + Delay: Wend TimerValue = TimerValue - 0.1 Mins = Int(TimerValue) \ 60 Secs = TimerValue - (Mins * 60) TimerCell.Value = Format(Mins, "00") & ":" & Format(Secs, "00.0") StartTime = Timer DoEvents Loop End Sub
this clock will run in A1 with running time and in A2 is will show Date and time (running time) depends on cell format
------------------------------------Code:Dim RunClk As Boolean '----------------------- Sub RunPauseClk() RunClk = Not (RunClk) Do While RunClk = True DoEvents Range("A1") = TimeValue(Now) Range("A2") = Now() Loop End Sub
macro for running realtime clock:
---------------------------------------------------------Code:Dim SchedRecalc As Date Sub Recalc() Range("C4").Value = Format(Time, "hh:mm:ss AM/PM") Call SetTime End Sub Sub SetTime() SchedRecalc = Now + TimeValue("00:00:01") Application.OnTime SchedRecalc, "Recalc" End Sub
To add date, just add:
after sub Recalc() in above macroCode:Range("C3").Value = Format(Now, "dd-mmm-yy")
=========================================================
disable the running realtime clock (stopping the clock):
Code:Sub Disable() On Error Resume Next Application.OnTime EarliestTime:=SchedRecalc, Procedure:="Recalc", Schedule:=False End Sub
I want to get the total active time and keep it permanent even sheet is open after weeks.
My requirements are as followed:
At 5:30pm I have entered some time values on A (4:15pm) and date on B (31-07-2011) then I need a clock to start ticking on E starting 00/00:00:00hrs (dd/hh:mm:ss) but it was already 01:15:00 hour delayed so clock should start with 01:15hrs saying that activity was already started 01:15hrs before and keep running the clock on E till I enter the finish time on C (08:15) and date (31-07-2011)on D then I should have total time of the activity automatically (00/02:45:00) on E
Many thanks,




Reply With Quote