How to create a countdown timer in Office Scripts.

Terzinski, Tyde 5 Reputation points
2024-01-17T21:25:55.4333333+00:00

I am able to create a countdown timer in Excel with VBA, but we are required to use Excel web with scripts. Does an equivalent for VBA's "Application.OnTime" exist in office scripts?

End goal is to setup two buttons:

  1. start timer from 0:00 and count up by 1 second each second
  2. stop timer

below is the VBA code I've used for countdown timers but I cannot convert it to scripts if Application.OnTime does not exist in office scripts.

Thanks!

 Sub timer()

     interval = Now + TimeValue("00:00:01")

     If Range("A1").Value = 0 Then Exit Sub

     Range("A1") = Range("A1") - TimeValue("00:00:01")

     Application.OnTime interval, "timer"

 End Sub
Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.