Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Problem writing formulas - please, please help!

Hello,

I have a problem that is driving me nuts.

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.

Just to drive me crazy this snippes works:

s = "=" & Chr(34) & "Test" & Chr(34)
Data.Cells(OFormulaValueRow, OFormulaValueCol).Formula = s

so it is not the quotation mark or the cell references that do not work.

Any help is greatly, very greatly appreciated,

Oliver




  #2   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange problem writing Excel formulas using .NET John Brock Excel Discussion (Misc queries) 4 August 29th 08 04:29 AM
writing formulas David Cheeks New Users to Excel 2 August 29th 08 12:00 AM
Problem writing Excel formulas via ODBC srikantha Excel Worksheet Functions 1 June 21st 05 06:28 PM
Problem writing Excel formulas via ODBC srikantha Excel Discussion (Misc queries) 0 June 21st 05 08:24 AM
Writing Formulas Irv Excel Worksheet Functions 2 December 28th 04 09:25 PM


All times are GMT +1. The time now is 09:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"