Welcome
Welcome to <strong>SpreadCE / Spread32</strong>.

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

stopwatch macro

Post your comments, questions, bug reports and feature requests here.

stopwatch macro

Postby ensajg on Tue Jul 28, 2009 12:39 pm

Hi

I am new to SpreadCE, and would like to make a macro for a simple stopwatch that will start and then continue to count up in time until another button is pressed. I can use the =FORMULA(NOW()) command in the macro to get the current time but I cannot get it to continually display the counting time.
Please can anyone help?

Andy
ensajg
 
Posts: 2
Joined: Tue Jul 28, 2009 12:20 pm

Postby stephenbye on Thu Jul 30, 2009 6:15 pm

Hi Andy,

I can't immediately think of a way to get a continually updated display of the time.

You could have a "Start" button that places the current time in one cell, and a "Stop" button that places the current time in another cell, and then have a formula that calculates the elapsed time by subtracting the start time from the stop time.

Depending on your computer, the time might only be accurate to a resolution of 1 second.

You would be better off finding a specialised stopwatch application.
stephenbye
Site Admin
 
Posts: 157
Joined: Sun Aug 12, 2007 11:56 pm

Stopwatch macro

Postby ensajg on Fri Jul 31, 2009 4:10 pm

Hi Stephen

thanks for your reply, I am hoping to create a stopwatch that will time a vehicle traveling around a circuit 7 times. I would like to compare each lap time with a cumulative target time to see how early or late the vehicle is so that feed back can be given to the driver to speed up or slow down to finish on time. Timing to a resolution of 1 second is fine as each lap is approx 6 minutes. As you say, it can be done by calculating the difference between 2 recorded times, I was hoping that there might be some way of showing the running time as it increased without having to press a refresh button regularly.
I have seen an excel counting stopwatch with the following VBA code and had wondered if anything equivalent was possible in SpreadCE:

Public stopMe As Boolean
Public resetMe As Boolean
Public myVal As Variant
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 1 Then
If Target.Value = myVal And Target.Value <> "" Then
'Changed
Dim startTime, finishTime, totalTime, timeRow
startTime = Timer
stopMe = False
resetMe = False
myTime = Target.Offset(, 2).Value
Target.Offset(, 1).Select
startMe:
DoEvents
timeRow = Target.Row
finishTime = Timer
totalTime = finishTime - startTime
Target.Offset(, 1).Value = Format(myTime + totalTime, "0.0000") & " Seconds"
If resetMe = True Then
Target.Offset(, 1).Value = 0
Target.Offset(, 2).Value = 0
stopMe = True
End If
If Not stopMe = True Then
Target.Offset(, 2).Value = totalTime
Goto startMe
End If
Cancel = True
End
Else
'Not Changed
stopMe = True
Cancel = True
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
myVal = Target.Value
End Sub

(if you enter a value in column A, and then double click on it the stopwatch will start. to end double click on a blank cell!)

Thanks for your help, I have looked for a suitable laptiming program for Pocketpc3 that will do what I need but without success.

Andy
ensajg
 
Posts: 2
Joined: Tue Jul 28, 2009 12:20 pm


Return to General

Who is online

Users browsing this forum: No registered users and 0 guests

cron