I am trying to use VBA to to insert a formula in excel that would look like the following in excel:
=BDH(C2,\"PX LAST\",F2,\"\",\"Dir=H\",\"days=w\",\"DTS=H\",\"
You should not be putting the Cells
inside the formula string, and you should be using the Address
property:
formulaString = "=BDH(" & Cells(i,3).Address(False, False) & ",""PX LAST""," & Cells(i,6).Address(False, False) & ","""",""Dir=H"",""days=w"",""DTS=H"",""cols=1;rows=1"")"
However what you actually want is switching to the R1C1 notation:
formulaStringR1C1 = "=BDH(RC3,""PX LAST"",RC6,"""",""Dir=H"",""days=w"",""DTS=H"",""cols=1;rows=1"")"
and then using
Cells(i,8).FormulaR1C1 = formulaStringR1C1