+ Reply to Thread
Results 1 to 2 of 2

Excel storing the time every time I press Lap button in the stopwatch

Hybrid View

  1. #1
    Registered User
    Join Date
    03-16-2022
    Location
    Portugal
    MS-Off Ver
    Microsoft Excel 2016
    Posts
    1

    Excel storing the time every time I press Lap button in the stopwatch

    Good evening everyone,

    I am new to this forum and I needed some help with a stopwatch, I know that one can make a stopwatch using excel, and I wanted it to store the time measured everytime I press "lap" button, can someone help me?

    Thank you!!

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,442

    Re: Excel storing the time every time I press Lap button in the stopwatch

    Code from one project :


    Public NextTime As Date
    
    Sub Start_Pause_Project()
        Dim NextRow As Long
        With Sheet1.Shapes("Rectangle 1")
            Select Case .TextFrame.Characters.Text
                Case "START"
                    NextRow = Range("B" & Rows.Count).End(xlUp).Row + 1
                    Start_Clock
                    With Range("B" & NextRow)
                        .Value = Time
                        .NumberFormat = "h:mm AM/PM"
                    End With
                    With Range("D" & NextRow)
                        .Value = Date
                        .NumberFormat = "d.mm.yy"
                    End With
                    .TextFrame.Characters.Text = "PAUSE"
                    .Fill.ForeColor.SchemeColor = 52    'Orange
                Case "PAUSE"
                    Stop_Clock
                    .TextFrame.Characters.Text = "RESUME"
                    .Fill.ForeColor.SchemeColor = 50    'Lime Green
                Case "RESUME"
                    Start_Clock
                    .TextFrame.Characters.Text = "PAUSE"
                    .Fill.ForeColor.SchemeColor = 52    'Orange
            End Select
        End With
    End Sub
    
    Sub Stop_Project()
        Dim Lastrow As Long
        If Range("C3").Value > 0 Then
            Lastrow = Range("B" & Rows.Count).End(xlUp).Row
            Stop_Clock
            With Range("C" & Lastrow)
                .Value = Time
                .NumberFormat = "h:mm AM/PM"
            End With
            With Range("E" & Lastrow)
                .Value = Range("C3").Value
                .NumberFormat = "[h]:mm:ss"
            End With
            Range("C3").Value = 0
            With Sheet1.Shapes("Rectangle 1")
                .TextFrame.Characters.Text = "START"
                .Fill.ForeColor.SchemeColor = 50    'Lime Green
            End With
        End If
    End Sub
    
    Private Sub Start_Clock()
        NextTime = Now + TimeValue("00:00:01")
        Range("C3").Value = Range("C3").Value + TimeValue("00:00:01")
        Application.OnTime NextTime, "Start_Clock"
    End Sub
    
    Private Sub Stop_Clock()
        If NextTime > 0 Then
            Application.OnTime NextTime, "Start_Clock", Schedule:=False
            NextTime = 0
        End If
    End Sub
    Two workbooks attached :
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Restart stopwatch from previous time
    By aozarski in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2018, 03:06 PM
  2. Formatting Time Label in Excel UserForm StopWatch
    By Mr.Biscuit in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2014, 12:14 PM
  3. Return Military Time for Stopwatch
    By gclode in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2014, 06:25 PM
  4. Stopwatch displaying elapsed time
    By Huwbob in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-09-2009, 05:52 AM
  5. Stopwatch time frustrations
    By smorris in forum Excel General
    Replies: 3
    Last Post: 01-30-2007, 04:04 PM
  6. Display Elapsed Time like a Stopwatch
    By avveerkar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-22-2006, 02:15 PM
  7. Run a stopwatch for time then execute code
    By JFamilo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2005, 10:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1