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

AttachmentSize
InsertDelay.xlsm11.66 KB