Avatar of Bright01
Bright01
Flag for United States of America asked on

Automatic refresh function by interval

EE Pros,

I'm doing testing on what needs to appear as "real time data" and statistics on different Sensors.  I need to start out easy on this so I have attached a spreadsheet that has a Column E that needs to be refreshed at a particular frequency (in seconds) -- perhaps set up as a simple looping exercise.  So when the sheet is open, it will automatically fire off the function to randomly produce new data at the frequency specificed.

Also, this change in the function should not update any other =randbetween( , ) calculations.
C--Data-Temp-Date-Time-Calculation.xls
Microsoft Excel

Avatar of undefined
Last Comment
Bright01

8/22/2022 - Mon
FamousMortimer

Hi,

Does this work for you?  You can change the code in TheSub to whatever you need it to do and change the variable cRunIntervalSeconds to the interval in number of seconds you want it to run.  Right now I just set it to calculate the activesheet which will recalc your random functions
Bitsqueezer

Hi,

that can't be done with a function but you can use the "Workbook Open" event to start a timer using the "Application.OnTime" method (see Excel help for further details).

With this you can specify a VBA procedure which updates the wanted cell(s) to the wanted values at the given time and then it only needs to use the Application.OnTime method again to set the next interval (Now() plus 5 seconds).

Of course you would need to save the file as macro enabled file.

Cheers,

Christian
FamousMortimer

Your help has saved me hundreds of hours of internet surfing.
fblack61
Bright01

ASKER
FamousMortimer,

I downloaded the WS but there is no Sub.

B.
ASKER CERTIFIED SOLUTION
FamousMortimer

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Bright01

ASKER
FamousMortimer,

Thank you!  Great work!

B.
FamousMortimer

You are very welcome.  Glad to help and thanks for the grade!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Bright01

ASKER
I'm posting a version 2 request.  Hope you will pick it up!

B.