Initially I turn on automatic calculation.
There are 2 worksheets: A1 and B1.
A1 pulls data from Bloomberg API constantly. (I am using BDP LAST_PRICE.)
B1 takes the data from A1 to do some calculations.
Now I need to turn off automatic calculation every 10 minutes or so.
I am using Application.OnTime to schedule a macro to turn off Excel automatic calculation.
According to: https://docs.microsoft.com/en-us/office/vba/api/Excel.Application.OnTime, Application.OnTime will only run when Excel is in "Ready, Copy, Cut, or Find mode".
Given the data updates constantly and we are doing constant calculations, Excel will never be in one of those modes. Therefore, the Application.OnTime macro will never execute.
Below are the methods I tried:
I set "LatestTime" parameter to 10 seconds after "EarliestTime" but it does not seem to work.
Instead of scheduling in the future, I Call a new function whenever an iteration is complete and try to wait for some time. The rough structure is as follows:
Sub QuitAuto()
Application.Wait (Now + TimeValue("00:00:10"))
'Turn off auto
Call wait_func
End Sub
Sub wait_func()
Application.OnTime ..."AnotherIter"
End Sub
Sub AnotherIter()
'Turn on auto
Call QuitAuto
End Sub
In this case, Application.WaitTime is going to stop both the macro and the data pulling process.
I also tried a while loop & doEvents approach, Excel is not frozen but the data pulling process still does not seem to work.
Is there any way to bypass the "low privilege" of the Application.OnTime issue?
Or is there any way to let the macro wait and at the same time let the Excel formula run in the background?
Worksheet_Calculate()event? If so, you could use that event to execute your scheduled task. Create a Module scoped variable to hold the scheduled time, and checkIf Now() >= ScheduledTime Thento trigger your required code - chris neilsen