excel - VBA 布隆伯格公式
问题描述
我的代码有问题,这里是:
Sheets("Data - Backtest").Cells(5, linCompteur - 1).FormulaR1C1 = _
"=BDH(R[-3]C[1],""PX_LAST"",""ED-"" & " & .Cells(6, 5).Value & " & ""AYA""," & .Cells(7, 5).Value & ", **""per="" & " & .Cells(9, 6).Value & "** , **""fx="" & " & .Cells(8, 5).Value & "** ,""Days=W"",""Fill=P"",""cols=2"")"
在 Excel 中它给出了这个,
=BDH(R[-3]C[1];"PX_LAST";"ED-" & 5 & "AYA";; **"per=" & d**; **"fx=" & EUR**;"Days=W";"Fill=P";"cols=2")
我知道问题出在哪里,是 d 和 EUR,应该是这样的:
=BDH(R[-3]C[1];"PX_LAST";"ED-" & 5 & "AYA";;**"per=" & "d"**;**"fx=" & "EUR"**;"Days=W";"Fill=P";"cols=2";"cols=2;rows=1305")
但我不知道如何为 VBA 中的等效项执行此操作。
解决方案
我将一些字符串连接放在一起,似乎没有任何理由将它们分开。
workSheets("Data - Backtest").Cells(5, linCompteur - 1).FormulaR1C1 = _
"=BDH(R[-3]C[1], ""PX_LAST"", ""ED-" & .Cells(6, 5).Value & "AYA"", " & .Cells(7, 5).Value & ", ""per=" & .Cells(9, 6).Value & """ , ""fx=" & .Cells(8, 5).Value & """ , ""Days=W"", ""Fill=P"", ""cols=2"")"
这是工作表上的结果。
=BDH(R[-3]C[1], "PX_LAST", "ED-5AYA", , "per=d" , "fx=EUR" , "Days=W", "Fill=P", "cols=2")
推荐阅读
- android - 反应本机错误[TypeError:网络请求失败] - 错误
- javascript - 具有不同名称但扩展同一个类的多个类
- c++ - C++,将 bool 设置为 false,返回 old
- node.js - 我们*应该*提交 .env 文件……但是如何提交?
- python - 我可以使用一个 pandas 表作为另一个表的映射表吗?
- sql - SQL中是否有按月自动生成更多行的函数?
- python - 如何在熊猫中将行转换为单行?
- sql - 在 WHERE 子句中使用 CASE 或 AND/OR 来限制结果
- java - 在 Libgdx 中渲染复杂物体
- discord.py-rewrite - dpymenus,discord.py 如何在菜单中获取当前选定的页面