VBA彭博公式

问题描述 投票:1回答:1

我的代码有问题,这里是:

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中的等价物做到这一点。

excel vba formula bloomberg
1个回答
2
投票

我把一些字符串连接在一起,似乎没有任何理由将它们分开。

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")
© www.soinside.com 2019 - 2024. All rights reserved.