Creating non-object events
This recipe deals with objects other than workbooks and worksheets. The principle is, however, exactly the same as with the previous events; an action of sorts triggers the event. Let's get working!
Getting ready
Open Excel and activate a new workbook. Save the file as a macro-enabled file on your desktop and call it NonObjectEvents
. Sheet1 should be active. Press Alt + F11 to switch to the VBA Editor.
How to do it…
When dealing with workbook and worksheet events, we created code for the event in the object's code window. Non-object events are exactly what the name says; events that are not associated with objects. These events are programmed in a normal VBA module.
- Insert a new module in the VBA Editor; Insert | Module.
- Enter the following code in the code window:
Sub WakeUpCall() Â Â Â Â Application.OnTime 0.5, "Alarm" End Sub
- Create a second Sub procedure – the one that is referred...