VBA to refresh Bloomberg data not running in proper order

后端 未结 3 1485
[愿得一人]
[愿得一人] 2020-12-06 03:34

my purpose is to update Bloomberg data and do some calculatations with different tickers. But it seems that VBA will run all the calculations without waiting the data to be

3条回答
  •  醉梦人生
    2020-12-06 04:34

    Bloomberg formulae update is asynchronous so your code won't wait until the update is over. You need to schedule the rest of your code to a later time, check if the data has been updated.

    It would look like this:

    Application.Run "RefreshCurrentSelection"
    update
    
    Sub update()
      If (check if the links have been updated) Then
        Worksheets("sheet1").Range("d3").Value = Worksheets("sheet1").Range("sum")
      Else
        Application.OnTime earliestTime:= Date + Time + timeserial(0, 0, 1), _
                       procedure:="update", Schedule:=True
      End if
    End Sub
    

    That would ask the Bloomberg API to refresh the data, then wait 1 second, check if the data is updated, wait another second if not etc. until the data is updated and then it would run the range assignment.

提交回复
热议问题