title: Can't get Pause Button to resume time properly - Excel VBA
body: <p>I am coding a Stopwatch Timer in Excel, and I am trying to add a pause button that will stop the timer, also resume when clicked the 2nd time. I have it almost working, but when it resumes it does not continue the stopwatch at the same time, but rather includes all of the elapsed time. The way I have it working is that when you click the pause button it adds the value of "Paused" to a cell and sets the application to "False". If the button is clicked and the cell already says "Paused" it will empty the cell value and call the StartTimer sub and start the timer again.</p>
  
  <p><em>Example of problem: If I press the button at 1min and 3secs, wait 3mins and resume the timer, it starts counting again at 4min and 3secs.</em></p>
  
  <p><strong>Example of goal: If I press the button at 1min and 3secs, wait 3mins and resume the timer, it should start counting again at 1min and 4secs.</strong></p>
  
  <p>Here is my current code that i've been working on:</p>
  
  <pre><code>Dim NextTick As Date, t As Date
  Sub StartStopWatch()
  t = Time
  Call StartTimer
  End Sub
  
  Sub StartTimer()
  NextTick = Time + TimeValue("00:00:01")
  Range("M1").Value = Format(NextTick - t - TimeValue("00:00:01"), "hh:mm:ss")
  Application.OnTime NextTick, "StartTimer"
  End Sub
  
  Sub StopTimer()
  
  On Error Resume Next
  Application.OnTime EarliestTime:=NextTick, Procedure:="StartTimer", Schedule:=False
  
  End Sub
  
  Sub ResetTimer()
  Range("M1").ClearContents
  Range("N1").ClearContents
  Range("L2").ClearContents
  End Sub
  
  Sub PauseButton()
  
  If Range("L2").Value = "" Then
  
  Range("L2").Value = "Paused"
  
  Application.OnTime EarliestTime:=NextTick, Procedure:="StartTimer", Schedule:=False
  
  Else
  Range("L2").ClearContents
  Call StartTimer
  
  End If
  
  End Sub
  </code></pre>