VBA & Macro Problems

Fix Excel VBA Application.OnTime Not Working with a One-Second Delay

Natalie TaylorNatalie Taylor Nov 13, 2026 869 views

Question details

The user needs to schedule and cancel a VBA macro with Application.OnTime using a one-second delay, but the timer does not work when the time is created from a string.

Fix Excel VBA Application.OnTime Not Working with a One-Second Delay
Product
WPS Office Spreadsheet / Microsoft Excel VBA
Device & OS
not provided
Scenario
The user is scheduling a delayed or recurring macro in Excel VBA and wants reliable one-second scheduling and cancellation.
Observed behavior
Application.OnTime does not work or cannot be cancelled reliably when the time value is assigned from a string such as "00:00:01".
Before you start

Enable the Developer tab and confirm that macros or VBA projects are allowed to run. Press Alt+F11 to open the VBA editor and locate the module where the macro is stored.

Solution 1Recommended

Store the Scheduled Time in a Public Date Variable

Use this solution when Application.OnTime does not fire or cannot be cancelled because the time is being created from a string.

Application.OnTime expects the EarliestTime argument as a Date value, not a string. Storing the scheduled time in a public Date variable lets you schedule and later cancel the same event reliably.

1
Open the VBA editor

Press Alt+F11 in WPS Spreadsheet or Excel to open the VBA editor, then locate the module containing your macro.

2
Declare a public Date variable

At the top of a standard module, enter `Public TimerTime As Date` so the scheduled time is visible to scheduling and cancellation code.

3
Assign the time with TimeValue

In your schedule procedure, set `TimerTime = Now + TimeValue("00:00:01")` instead of using a string directly.

4
Schedule the macro

Run `Application.OnTime EarliestTime:=TimerTime, Procedure:="ProcedureName"` using the stored Date value.

5
Cancel the timer safely

To stop the scheduled event, call `Application.OnTime EarliestTime:=TimerTime, Procedure:="ProcedureName", Schedule:=False` with the same stored time.

Reliable scheduling: Storing the time as a Date allows Application.OnTime to fire and be cancelled reliably.
WPS Spreadsheet VBA Macro Solution

Schedule Excel-Compatible Macros Reliably with WPS Spreadsheet

Open the VBA editor in WPS Spreadsheet, store the scheduled time in a public Date variable, and use Application.OnTime with Now + TimeValue to create a cancellable one-second delay.

  1. 1. Open WPS Spreadsheet: Launch WPS Office Spreadsheet and open the workbook that contains your macro.
  2. 2. Open the VBA editor: Press Alt+F11 to open the Microsoft Visual Basic for Applications editor in WPS Spreadsheet.
  3. 3. Insert or open a module: In the Project Explorer, select your workbook and insert or open a standard module where the macro code is stored.
  4. 4. Enter the Date-variable schedule code: Declare `Public TimerTime As Date`, assign `TimerTime = Now + TimeValue("00:00:01")`, and call `Application.OnTime EarliestTime:=TimerTime, Procedure:="ProcedureName"`.
  5. 5. Run and cancel the macro: Run the schedule procedure, and use `Application.OnTime EarliestTime:=TimerTime, Procedure:="ProcedureName", Schedule:=False` to cancel the same event when needed.
WPS Spreadsheet supports VBA macro editing for Excel-compatible workflowsFree to use and lightweight compared with Microsoft OfficeOpens and saves .xlsm and .xlsx files with formatting and macro modules intactFamiliar ribbon and VBA editor make migration straightforwardStore scheduled times as Date values for reliable macro scheduling
microsoft office alternative - wps office

Frequently Asked Questions

Why does Application.OnTime not work when I use "00:00:01" as a string?

Application.OnTime expects a Date value for EarliestTime. A string like "00:00:01" may not be converted to the correct Date at runtime, so store the time in a Date variable: `TimerTime = Now + TimeValue("00:00:01")`.

How can I cancel a scheduled Application.OnTime event in Excel VBA?

Call Application.OnTime with the exact same EarliestTime and procedure name, and set `Schedule:=False`. Storing the time in a public Date variable makes this reliable.

Does WPS Spreadsheet support Excel VBA macros and Application.OnTime?

WPS Spreadsheet includes a VBA editor and supports Excel-compatible macro workflows. Open it with Alt+F11 and use the same Application.OnTime syntax in a standard module.

Where do I declare the TimerTime variable?

Declare `Public TimerTime As Date` at the top of a standard VBA module so both the scheduling and cancellation code can access the same stored time.

What is the correct macro syntax for a one-second delayed procedure?

Use `TimerTime = Now + TimeValue("00:00:01")` and then `Application.OnTime EarliestTime:=TimerTime, Procedure:="ProcedureName"` to schedule the procedure one second from now.