Timing Delays in VBA

后端 未结 12 2241
陌清茗
陌清茗 2020-11-28 13:48

I would like a 1 second delay in my code. Below is the code I am trying to make this delay. I think it polls the date and time off the operating system and waits until the

12条回答
  •  时光取名叫无心
    2020-11-28 14:19

    You can copy this in a module:

    Sub WaitFor(NumOfSeconds As Long)
    Dim SngSec as Long
    SngSec=Timer + NumOfSeconds
    
    Do while timer < sngsec
    DoEvents
    Loop
    
    End sub
    

    and whenever you want to apply the pause write:

    Call WaitFor(1)
    

    I hope that helps!

提交回复
热议问题