troubleshooting Question

Problem setting a text with VBA in Excel cells

Avatar of Bernard Thouin
Bernard ThouinFlag for Switzerland asked on
Microsoft Excel
3 Comments1 Solution548 ViewsLast Modified:

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.
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros