View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jan Karel Pieterse Jan Karel Pieterse is offline
external usenet poster
 
Posts: 535
Default Problem writing formulas - please, please help!

Hi Oliver,

The following code fails:

Dim s As String
s = "=VLOOKUP(" & Chr(34) & "Timeline" & Chr(34) &
";ScenarioLookUp;2;FALSE)"
Data.Cells(OFormulaValueRow, OFormulaValueCol).Formula = s

whereas when you copy the string s and paste it into a cell manualy, it
gives the correct result.


Because VBA speaks American, it expects you to use the comma as the
argument separator.

I suspect this will work:

Dim s As String
s = "=VLOOKUP(" & Chr(34) & "Timeline" & Chr(34) &
",ScenarioLookUp,2,FALSE)"
Data.Cells(OFormulaValueRow, OFormulaValueCol).Formula = s

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com