Question: I would like to use a simple VBA script to call the Bloomberg BDH function in specific locations of my spreadsheet, which is computationally primitive.

While the use of standard Excel functions doesn't see to be a problem, as soon as I insert the parts of the Bloomberg function that contain quotation marks (such as "Dates,Period", "H,M") I get an *expected end of statement* error.

All I want to do is insert these function calls into specified cells. Unfortunately I have no experience with VBA and don't know why the quotation marks seem to mess it up.

Is there an alternative for the =BDH function which doesn't use symbols that VBA doesn't like? Or is there any other way to insert a Bloomberg function into a specified cell using a marco?

Any help would be greatly appreciated!

Here's the exact code I am trying to use:

```
Range("B16").Value = "=BDH("TSLA", "PX_LAST", "01/01/2014", "01/03/2014", "Period, Dates", "M,H")"

```

Answer: 
You have to escape the quotes with more quotes. It also doesn't hurt to set the formula property instead of setting the value, but it isn't necessary for this to work. It's the quotes that are causing the compiler error.

```
Range("B16").Formula = "=BDH(""TSLA"", ""PX_LAST"", ""01/01/2014"", ""01/03/2014"", ""Period, Dates"", ""M,H"")"

```
The [syntax I found](http://library.nd.edu/eresources/guides/bloomberg/FunctionReference.pdf) has the optional settings at the end being set as "Setting=x, OtherSetting=y" which would be how my formula below is set up:

```
Range("B16").Formula = "=BDH(""TSLA"", ""PX_LAST"", ""01/01/2014"", ""01/03/2014"", ""Period=M, Dates=H"")"

```