本文介绍了如何在Microsoft Visual Basic(VBA for Excel)中使用Bloomberg Data History(BDH)命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用简单的VBA脚本在电子表格的特定位置调用彭博BDH功能,这在计算上是原始的。

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.

虽然使用标准Excel函数不会成为问题,只要我插入包含引号的彭博功能部分(例如日期,期间,H,M),我会得到一个预期的结尾语句错误。

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.

我想做的是将这些函数调用插入到指定的单元格中。不幸的是,我没有VBA的经验,不知道为什么引号似乎搞砸了。

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.

有没有一个替代的= BDH函数不使用VBA不喜欢的符号?或者有什么其他方式可以使用marco将Bloomberg函数插入指定的单元格?

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?

任何帮助将不胜感激!

以下是我要使用的确切代码:

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")"


推荐答案

你必须用更多的引号来转义引号。设置公式属性而不是设置值也不会受伤,但这并不是必须的。这是导致编译器错误的引号。

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"")"

这篇关于如何在Microsoft Visual Basic(VBA for Excel)中使用Bloomberg Data History(BDH)命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 08:58