Sub delay(ts) Dim t, t1 t = Timer Do t1 = Timer If t1 < t Then t1 = 86400 + t1 DoEvents Loop Until t1 - ts > t End Sub