I have an Excel sheet with ~300,000 BDH formulas to download securities prices.
I want to
- open the file and get all prices
- paste them as values
- save and close the file.
However, I do not know when Excel finishes populating Bloomberg data, so it's difficult to determine the time to do 2) and 3).
I have written VBA, but not sure if it works:
In Module1
Sub CheckFormulas()
If Application.CalculationState = xlDone Then
With Worksheets("Sheet1").UsedRange
.Value = .Value
End With
Else
Application.OnTime Now + TimeValue("00:30:00"), "CheckFormulas"
ActiveWorkbook.Close Savechanges:=True
End If
End Sub
In 'ThisWorkbook'
Private Sub Run()
Call CheckFormulas
End Sub
So the way it should theoretically work is:
- I open the file
- the code checks every 30 minutes if all BDH formulas are done
- if they are done, then paste as values, save and close 4) if not, check 30 minutes later again.
I am wondering if this is the best way to accomplish my goal and want to know if Application.CalculationState
is compatible or works with Bloomberg formulas BDH?