Time Considerations in Excel Macros with ON.TIME() And WAIT()

Last reviewed: November 2, 1994
Article ID: Q45474
The information in this article applies to:
  • Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a, 5.0

SUMMARY

In Microsoft Excel, when you use the ON.TIME and WAIT macro functions, it is important to remember that there is no guarantee that the macro specified will run at exactly the time indicated.

Microsoft Excel guarantees only that the macro will run if it is at least the time indicated or the specified amount of time has elapsed since the ON.TIME or WAIT statement was executed.

MORE INFORMATION

To understand why Microsoft Excel, or any Microsoft Windows application, cannot guarantee an action to occur at a specific time, it is necessary to look at the Microsoft Windows operating environment.

Microsoft Windows functions as a messaging system, with each application receiving the processor for a period of time to handle any messages that are in its message queue.

If you use ON.TIME to execute the macro TEST.XLM at noon, Microsoft Excel will not run it before noon, but it is possible that Microsoft Excel may not run TEST.XLM until 12:05.

This delay occurs because Microsoft Excel may not have the processor at noon; another application may be processing messages in its message queue and may not release the processor until it is finished. When the other application releases the processor and Microsoft Excel gains control, it will process messages in its queue, including the one that tells it to run TEST.XLM.


KBCategory: kbusage
KBSubcategory:

Additional words: 5.00 2.0 2.00 2.01 2.1 2.10 3.0 3.00 4.00 4.0a
4.00a


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.