Run a code after delay
Ever wondered how to insert a delay while running a code.
In this blog I'll explain how to add delay before running a code.
Assumption:
A delay of 25 seconds needs to added before running the code.
Steps:
1. Open a new file
2. Press Alt+F11 to open VBA editor
3. In the left navigation window select ThisWorkbook
4. In the editor window enter the code below
5. Close the VBA editor
6. Save the file as Macro Enabled File
7. Test with you inputs
Code:
Sub InsertDelay()
Dim Delay As Variant
Dim Start As Variant
Delay = 25 'Change the value here for required delay in seconds
Start = Timer
Do While Timer < Start + Delay
Loop
End Sub
I think this has been informative and I thank you for viewing.
-Saurabh
Attachment | Size |
---|---|
InsertDelay.xlsm | 11.66 KB |
- saurabhlakhanpal's blog
- Login or register to post comments
- 3943 reads
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago