|
|
|
|
|
|
Excel
|
Create a timer to run a macro
|
|
Ease of Use
|
Intermediate
|
Version tested with
|
2010
|
Submitted by:
|
Paleo
|
Description:
|
A macro will be run after a certain time
|
Discussion:
|
Sometimes you create a macro you want to run several times, after a specified time interval.
When you run "minhaMacro" bellow you will make it run after each 15 minutes, and if you ever need it to stop, simply run "paraTimer".
|
Code:
|
instructions for use
|
Public Sub minhaMacro()
On Error Resume Next
MsgBox ("Time elapsed!")
Application.OnTime EarliestTime:=Now + TimeValue("00:15:00"), Procedure:="minhaMacro"
End Sub
|
How to use:
|
- Create a command button (cmdStart) for starting the counter, in the Main sheet
- Goto Excel --> Tools --> Macro --> Visual Basic Editor (Or Press Alt + F11)
- In VBE window, goto Insert --> Module
- Double Click the Module1 and paste the code shown above.
|
Test the code:
|
- Click the Start button.
|
Sample File:
|
timer.zip 15.5KB
|
Approved by Jacob Hilderbrand
|
This entry has been viewed 449 times.
|
|