Lap Timer and Running Average

Josh96

New Member
Joined
Nov 30, 2016
Messages
1
Hi there!

I'm trying to set up a lap timer in Excel, with the ability to do up to 100 laps. I've seen things like this are possible, but haven't found a useful source which explains to me how to do it. If anyone can point me in the direction of a good tutorial or something it'd be much appreciated!

However, I also want to be able to keep track of the average of the 10 most recent lap times. Is there a neat way to get Excel to be able to do this for me, or will I be stuck with having to do this manually?

Thanks in advance!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
try this on a blank file

Code:
Option Explicit
Private startTime As Single

Sub StartButton_Click()
    Range("A:B").ClearContents
    Range("A1") = "Start"
    startTime = Timer
End Sub
Sub LapButton_Click()
    Dim finalTime As Single, lr As Long
    finalTime = Timer - startTime
    lr = Cells(Rows.Count, "A").End(xlUp).Row + 1
    Cells(lr, "A") = Format(finalTime, "0.000")
    If lr = 2 Then Cells(lr, "B") = Cells(lr, "A")
    If lr > 2 Then Cells(lr, "B") = Cells(lr, "A") - Cells(lr - 1, "A")
End Sub

create 2 buttons
start button - will erase your data in column A & B the time to start over
lap button - will write the time in column A since the start button was pressed and in column B it will write the lap time

hth,

Ross
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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