excel - 在允许VBA读取代码的单元格中,使用VBA输入到期日期

  显示原文与译文双语对照的内容
116 3

在Excel图纸中,我有以下公式:

=BDS("SPX Index","CHAIN_TICKERS","CHAIN_POINTS_OVRD=ALL","CHAIN_STRIKE_PX_OVRD=ALL","CHAIN_EXP_DT_OVRD=201401","CHAIN_PUT_CALL_TYPE_OVRD=c","","cols=1;rows=201")

然后,在VBA中有以下代码,以便可以以按下条形码并获取所需的数据:

Private Sub CommandButton1_Click()
Dim options As String
Cells(2, 1).Formula = StringConcat("","=BDS(", _
Chr(34),"SPX Index", Chr(34),",", _
Chr(34),"CHAIN_TICKERS", Chr(34),",", _
Chr(34),"CHAIN_POINTS_OVRD=ALL", Chr(34),",", _
Chr(34),"CHAIN_STRIKE_PX_OVRD=ALL", Chr(34),",", _
Chr(34),"CHAIN_EXP_DT_OVRD=201401", Chr(34),",", _
Chr(34),"CHAIN_PUT_CALL_TYPE_OVRD=c", Chr(34),",", _
Chr(34), Chr(34),")")

这是正常工作,除了我想知道如果有什么我可以以用这一行:Chr(34),"CHAIN_EXP_DT_OVRD=201401", Chr(34),",", _当前,我必须硬编码,每次需要不同的月数据时都需要更改。我想知道是否有人能帮助我编码部分,从电子表格中的某些单元格来代替 of 。

时间:原作者:1个回答

69 4

这个?

Cells(2, 1).Formula ="=BDS(""SPX Index"",""CHAIN_TICKERS"",""CHAIN_POINTS_OVRD=ALL"",""CHAIN_STRIKE_PX_OVRD=ALL"",""CHAIN_EXP_DT_OVRD="" & $D$2 &"""",""CHAIN_PUT_CALL_TYPE_OVRD=c"","""",""cols=1;rows=201"")"

使用这里选项,范围("$d$2"),IE,单元格的( 2,4 ),允许你动态输入年份和月值。

原作者:
...