VBA for Stopwatch in a column

REUBEN

Board Regular
Joined
Mar 7, 2014
Messages
113
HI All,

I've been reading up about adding a stopwatch VBA in my sheet and make it really simple to use.

The sheet is to record time one is spending on their specific tasks. There is start time column, end time colum. And now I'm trying to add a break time column. I am using the following code to enter the start and end times by simply double clicking in the cells of the start time and end time columns:

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)    If Intersect(Target, Range("$B$2:$C$500")) Is Nothing Then Exit Sub
    Target = Time
    Cancel = True
End Sub

The idea is to have the option of starting a stopwatch counter by double clicking a cell next to the latest cell I've entered the start time in. and then double click that same cell to stop the stopwatch counter. Then when I'm done with the task finally, I double click the cell in the end time column.

Two questions I have are:
1) how to combine the double click feature as to a stop clock as I already am using the "Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)" code.
2) how to tweak the above code to only capture the hours and minutes (HH:MM) and not the seconds(SS).

Thank you.
Reuben
 
In case a user is in the break time running the Stopwatch (counter), and they need to now enter the start time for another task (in the next row). as the counter is running, one cannot exit it.

This is a limitation of VBA. It's modal. The easiest thing to do would be to make a break start and break end, just like the main start and end.

Secondly, and this may sort of link up to the previous question. If one has used the break time counter once and there is a value in the break time field, what should the code be tweaked to make the break watch continue counting or create another break time count?

Having break start and end on each line solves this problem too.
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Thank you.

But doing so would mean we do not use the cool stop clock feature. Also, how to account for multiple breaks one may need to take before the task/ case is complete? The reason is because each task or case may be spread over days.
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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