Hi,
I was trying to develop the following Excel VBA code. The main aim is for the code to be able to automatically recognize the dynamic inputs tfor the variables and run the Blooomberg BDH function on the variable values. But it seemed that the "" marks seems to be prohibiting the BDH function to take values from the data variables. After running the code, the formula that has been populated in the excel is "=BDH(tickername, pricetype,dtStart,dtEnd)" instead of =BDH formula that accounts for the variable values.
Can any expert enlighten me? thank you a lot!
Sub testBDH()
Dim dtStart As Date, dtEnd As Date
Dim tickername, pricetype As String
'then apply the values you've worked out. e.g.
dtStart = CDate("6/30/2010")
dtEnd = CDate("6/01/2011")
tickername = "ST SP Equity"
pricetype = "PX_LAST"
'then use the variables as follows
ActiveCell.FormulaR1C1 = "=BDH(tickername, pricetype,dtStart,dtEnd)"
End Sub
I was trying to develop the following Excel VBA code. The main aim is for the code to be able to automatically recognize the dynamic inputs tfor the variables and run the Blooomberg BDH function on the variable values. But it seemed that the "" marks seems to be prohibiting the BDH function to take values from the data variables. After running the code, the formula that has been populated in the excel is "=BDH(tickername, pricetype,dtStart,dtEnd)" instead of =BDH formula that accounts for the variable values.
Can any expert enlighten me? thank you a lot!
Sub testBDH()
Dim dtStart As Date, dtEnd As Date
Dim tickername, pricetype As String
'then apply the values you've worked out. e.g.
dtStart = CDate("6/30/2010")
dtEnd = CDate("6/01/2011")
tickername = "ST SP Equity"
pricetype = "PX_LAST"
'then use the variables as follows
ActiveCell.FormulaR1C1 = "=BDH(tickername, pricetype,dtStart,dtEnd)"
End Sub