ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   time delay refresh on random number (https://www.excelbanter.com/excel-worksheet-functions/254515-time-delay-refresh-random-number.html)

Bertrand[_2_]

time delay refresh on random number
 
Is it possible to have a time delay on a random number. For example the
random number refresh every x seconds.

ryguy7272

time delay refresh on random number
 
Read this:
http://www.cpearson.com/Excel/OnTime.aspx


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Bertrand" wrote:

Is it possible to have a time delay on a random number. For example the
random number refresh every x seconds.


Bernie Deitrick

time delay refresh on random number
 
Bertrand,

You could use the OnTime method to fire a macro that writes the random
number to a cell or a variable once every six seconds or so. Run Random6
once manually, and it will keep going until you decide to stop it. I have
chosen a 2 digit random number between 0 and 100 - you can change that
easily.

Dim DT As Date

Sub Random6()
DT = Now() + TimeValue("00:00:06")
Application.OnTime DT, "Random6"
Cells(Rows.Count, 1).End(xlUp)(2).Value = Round(Rnd() * 100, 2)
End Sub

Sub StopIt()
Application.OnTime DT, "Random6", , False
End Sub

To stop it, use StopIt


HTH,
Bernie
MS Excel MVP


"Bertrand" wrote in message
...
Is it possible to have a time delay on a random number. For example the
random number refresh every x seconds.




All times are GMT +1. The time now is 07:50 PM.

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