excel - Update Bloomberg API static data -
i want copy , paste data 1 sheet sheet. original data bloomberg api function. found bloomberg data cell updates after macro finishes running. tried build private function let static data update before copy it. here code:
private sub procesdata() application.run call application.ontime(now + timevalue("00:00:01"), "processdata") end sub sub macro3() dim integer = 1 until > 2 sheets("sheet1").activate cells(1, 3).value = cells(i, 1) = + 1 call application.ontime(now + timevalue("00:00:01"), "processdata") range("c4:e181").select selection.copy sheets("sheet2").select range("a1").select lmaxrows = cells(rows.count, "a").end(xlup).row range("a" & lmaxrows + 1).select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false loop end sub
ah, bloomberg api... many issue.
so, when bloomberg request using function call, cell call site receives call , refreshes data.
the problem is, w.r.t. automation, data can come in parts , have wait till completes before continuing process data.
so, there 3 approaches solution.
- last time looked, 1 bloomberg recommends. have routine refreshes call cell formula. this has timer , recursively invokes itself until data has been retrieved. trick know when data has been retrieved correctly. data area checked errors hasn't been completed yet.
- the other solution invoke call using application.run build formula in code , invoke vba. allows not deal functions such in worksheet. same thing 1.
- you can set reference bloomberg api , use com request. cleaner approach , can easier integrate code creating bloomberg data call api.
i suggest, if possible going option 3. although little more effort, te code becomes cleaner. options 1. , 2. can tricky debug when workbooks become more complex in terms of structure etc.
if search bloomberg (the ever tremendous old 'f1 f1' service should able point in right direction. impressive system ever done in opinion!) bloomberg have examples demonstrate methods highlighted above.
so, issue @ hand , answer question :) restructure code function call calcuation (which invoke requests bloomberg). enter recursive function calls until there no errors in data. after copy data.
hope helps.
Comments
Post a Comment