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
Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
2,161 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,262 questions
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.