I'm trying to "prepare" an Excel (2007 SP3) spreadsheet to make calls to Bloomberg functions to get some stock exchange data automatically. To do that, I have to insert in a number of cells a call to a Bloomberg function, which is not valid on my PC, because the spreadsheet is going to run and get its data on a separate Bloomberg-equipped, highly restricted machine, and the called Bloomberg function is only available on that machine. However, I'd like the user who is going to "run" the Excel to only have an absolute minimum of handling to do, hence my goal to give him a ready-to-run Excel.
What I want to insert in some part of the Excel is, for a given cell, something like this:
I build this string with VBA code, but when I say:
Cell(x,y) = sTemp ' sTemp is the string holding the text "=BDP($B2;C$1)"
I get an error ("Application-defined or object-defined error"), presumably because the formula is not valid, as the BDP function is not defined on my machine. So I added an error ignoring statement:
myrange.Errors.Item(xlInconsistentFormula).Ignore = True 'myrange is the cell area
but that also generates an error, actually the same error as on the cell setting statement.
How can I still insert such an invalid formula in my Excel ? Is that just impossible, i.e. should that part of the VBA code run only when the spreadsheet is on the "Bloomberg machine" ? Or am I missing something ?
And why is the error-ignoring statement generating an error ?
Thanks for help.