question

Upvotes
Accepted
1 1 1 4

Is there a way to get VBA to pause and wait for TR and RSearch formulas to update?

Basically I am trying to write a macro that loops through a list of RIC's.

In the worksheet every time the RIC is updated, the TR and RSearch functions in there need to update, the sheet needs to recalculate and then some of the results get posted to a report that the VBA macro handles later on. My problem is that if I just let the macro run then the loop continues to the end of the list of RICs before any of the cells in the worksheet have time to update. If I pause the macro, it just sits there, and the TR and RSearch fields never get updated.

I am told that due to the asynchronous nature of the TR API, it is not possible to do this within a single macro, so I am wondering if there is some kind of workaround for this? - or do I need to let the user wait for the updates to happen, and then "manually" click a button that picks the next RIC in the list and so on?

eikoneikon-com-apiexcel
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
4.6k 26 7 22

@PeterG, I do not believe that you can achieve this in a manner that will produce sustainable solution.

Since you need to control the stages of execution, I suggest that you use the COM API for search (RSearch), real-time data (AdfinX Real-time), analytics (Adfin Analytics), time series (RHistory) and reference data (DEX2).

All the tutorials can be found here.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
31 0 1 3
@PeterG I also have this problem even with the APIs. Does anyone know how i can automate the data request to loop and refresh the data each time? It doesn't refresh whilst in VBA.

Thanks

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

@james.jeffery

Could you provide more details on this please?

If you are using AdfinX Real-time, you have streaming updates, and your OnUpdate() event handler will be called each time there is an update on the RIC that you subscribe to.

Here is the tutorial that walks you through this process, check out the sample that uses RT_MODE_ONUPDATE parameter on start.

@james.jeffery

If you need to run discrete calculations, there are several ways to do that:

  1. Start AdxRtList subscription with the RT_MODE_ONUPDATE parameter and check on the data only when you need it with ListItems() and ListFields() functions;
  2. Start AdxRtList in the snapshot mode with RT_MODE_ONIMAGE and get the response only once.
Click below to post an Idea Post Idea