Nilesh’s Weblog

August 12, 2008

Sleep in VBA

Filed under: Microsoft Excel — Tags: , , — deshnilesh @ 11:08 am

Here’s another known trick for VB/VBA, if you code a lot in C/Java and then switch to VB/VBA you might be surprized to know that there is no sleep function in VB. However there is a hack to implement it.

Just refer the library kernal32 for Sleep function and then use it!! Simple isn’t it?

This is what you need to put in –

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

The function can be called as usual –

Sleep (2000)

Create a free website or blog at