Excel Stopwatch for Multiple Clients

cdb0ewm

Board Regular
Joined
Aug 11, 2012
Messages
66
Each day I get a list of clients that I have to track the time I spend doing various activity. The complicating part of this is that I will start working on one client, have to pause and work on another client, then potentially go back to the first client or other clients. I may have to hit the Start and Pause buttons several times during the day for a single customer. I envision a spreadsheet like:

Client Start Button Pause Button Stop Button Time Spent
Client A Button Button Button Time
Client B Button Button Button Time
Client C
ETC

I would appreciate any suggestions.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
One approach...

Excel Workbook
ABCDEFGH
1TotalTimeClientStart01Stop01Interval01Start02Stop02Interval02
20:00:37abc company14:01:5914:02:120:00:1314:02:1614:02:400:00:24
Sheet1



To enter the Start and Stop times, just one button that calls the following macro...

Code:
Sub InsertTime()
    ActiveCell.Value = Format(Time, "h:mm:ss")
End Sub

Cheers,

tonyyy
 
Upvote 0
Another approach…

- Each client would have a corresponding cell, linked to three buttons; start, stop and reset.
- Example below is for one client; when working with multiple clients and buttons, additional code can be used to identify which button was clicked and take proper action.

Cdb, please choose a method.

Code:
' sheet module
Dim StopTmr As Boolean, SchdTime As Date, Etime As Date
Const OneSec As Date = 1 / 86400#


Private Sub ResetBtn_Click()
StopTmr = 1: Etime = 0
[B3] = "00:00:00"               ' cell with timer
End Sub


Private Sub StartBtn_Click()
StopTmr = 0
SchdTime = Now()
[B3] = Format(Etime, "hh:mm:ss")
Application.OnTime SchdTime + OneSec, "Plan1.NxtTck"
End Sub


Private Sub StopBtn_Click()
StopTmr = True: Beep
End Sub


Sub NxtTck()
If StopTmr Then
   'Don't reschedule
Else
   [B3] = Format(Etime, "hh:mm:ss")
   SchdTime = SchdTime + OneSec
   Application.OnTime SchdTime, "Plan1.NxtTck"
   Etime = Etime + OneSec
End If
End Sub
 
Upvote 0
This is the code to determine which button was clicked:


Code:
Sub FButton()                                           ' associated to the button
Dim b As Object
Set b = ActiveSheet.Buttons(Application.Caller)         ' Form control
With b.TopLeftCell
    MsgBox "Column " & .Column & vbLf & "Row " & .Row
End With
End Sub
 
Upvote 0
- Tag: Excel multiple timers with VBA

- The code below manages three simultaneous stopwatches, each one independent with start, stop and reset buttons.

Code:
' sheet module
Dim StopTmr(1 To 3) As Boolean, SchdTime(1 To 3) As Date, Etime(1 To 3) As Date
Const OneSec As Date = 1 / 86400#
    
Sub NxtTck(i%)
If StopTmr(i) Then
   'Don't reschedule
Else
   Cells(5 * i - 3, 2) = Format(Etime(i), "hh:mm:ss")    ' cell with timer
   SchdTime(i) = SchdTime(i) + OneSec
   Application.OnTime SchdTime(i), "'Plan2.NxtTck """ & i & """'"
   Etime(i) = Etime(i) + OneSec
End If
End Sub


Sub FButton()                                           ' associated to each button
Dim b As Object, j%
Set b = ActiveSheet.Buttons(Application.Caller)         ' Form controls
Select Case b.TopLeftCell.Row
    Case 2: j = 1                                       ' row 2, first timer
    Case 7: j = 2                                       ' row 7, second timer
    Case 12: j = 3                                      ' row 12, third timer
End Select
Select Case b.TopLeftCell.Column
    Case 5                                              ' start buttons, column E
        StopTmr(j) = False
        SchdTime(j) = Now
        Cells(5 * j - 3, 2) = Format(Etime(j), "hh:mm:ss")
        Application.OnTime SchdTime(j) + OneSec, "'Plan2.NxtTck """ & j & """'"
    Case 9                                              ' stop buttons, column I
        StopTmr(j) = True
    Case 13                                             ' reset buttons, column M
        StopTmr(j) = True
        Etime(j) = 0
        Cells(5 * j - 3, 2) = "00:00:00"
End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,684
Members
449,048
Latest member
81jamesacct

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