ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   time delay (https://www.excelbanter.com/excel-programming/372048-time-delay.html)

RobcPettit[_2_]

time delay
 
Hi, I have live data streeming into a worksheet. Then I have a vba code
in the 'worksheet calculate'. 8 out of 10 times all works well. But for
those 2 times, my live data might glitch for a second or two(internet
connection times out, etc). Result bieng that all the data has not
fully updated, but the macro will cause to fire. I s there a way of
adding a 2 second delay when the macro fires.
Regards Robert


Dave Patrick

time delay
 
Try something like this.

Dim mytime As Date
Dim mydelay As Single
Dim myseconds As Integer
myseconds = 2
If myseconds 0 Then
mydelay = myseconds / 86400
Else
Exit Sub
End If
mytime = Now()
Do While Now() < mytime + mydelay
DoEvents
Loop


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"RobcPettit" wrote:
| Hi, I have live data streeming into a worksheet. Then I have a vba code
| in the 'worksheet calculate'. 8 out of 10 times all works well. But for
| those 2 times, my live data might glitch for a second or two(internet
| connection times out, etc). Result bieng that all the data has not
| fully updated, but the macro will cause to fire. I s there a way of
| adding a 2 second delay when the macro fires.
| Regards Robert
|



RobcPettit[_2_]

time delay
 
Thankyou Dave, I will give that a go today.
RegardS Robert


Dave Patrick wrote:
Try something like this.

Dim mytime As Date
Dim mydelay As Single
Dim myseconds As Integer
myseconds = 2
If myseconds 0 Then
mydelay = myseconds / 86400
Else
Exit Sub
End If
mytime = Now()
Do While Now() < mytime + mydelay
DoEvents
Loop


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"RobcPettit" wrote:
| Hi, I have live data streeming into a worksheet. Then I have a vba code
| in the 'worksheet calculate'. 8 out of 10 times all works well. But for
| those 2 times, my live data might glitch for a second or two(internet
| connection times out, etc). Result bieng that all the data has not
| fully updated, but the macro will cause to fire. I s there a way of
| adding a 2 second delay when the macro fires.
| Regards Robert
|



Dave Patrick

time delay
 
You're welcome.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"RobcPettit" wrote:
| Thankyou Dave, I will give that a go today.
| RegardS Robert




All times are GMT +1. The time now is 08:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com