Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Writing a word from VBA into excel


Reply
 
Thread Tools Display Modes
  #1  
Old 03-16-2009, 05:15 AM
jwvdpoll jwvdpoll is offline
Freshman
 
Join Date: May 2008
Posts: 36
Default Writing a word from VBA into excel


Hello,

I have a logical function:
Code:
Range("AS34").FormulaR1C1 = "=if(RC[-2]<RC[-1],Turbulent,Laminair)"
This checks the velocity of adjecent cells and puts either the words turbulent of laminair in its own cell. But if I do it like this excel will give a #NAME error and if I put " around the words in VBA it will give a syntax error.

How can I fix this.
Reply With Quote
  #2  
Old 03-16-2009, 05:40 AM
Technoboy Technoboy is offline
Freshman
 
Join Date: Jul 2008
Posts: 26
Default

Change to:

Code:
Range("AS34").FormulaR1C1 = "=if(" & _
        Range("AS34").Offset(0, -2).Address & "<" & _
        Range("AS34").Offset(0, -1).Address & ",""Turbulent"",""Laminair"")"
Note that the double quotes ("") mitigate the syntax error and in code represent a single set of quotes.

Last edited by Technoboy; 03-16-2009 at 05:42 AM. Reason: Incorrect Post
Reply With Quote
  #3  
Old 03-16-2009, 05:42 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline
Out Of Office

Retired Moderator
* Expert *
 
Join Date: Mar 2005
Location: London, UK
Posts: 3,398
Default

Code:
    Range("AS34").FormulaR1C1 = "=if(RC[-2]<RC[-1],""Turbulent"",""Laminair"")"
__________________
RAD Excel Blog
Reply With Quote
  #4  
Old 03-16-2009, 09:04 AM
jwvdpoll jwvdpoll is offline
Freshman
 
Join Date: May 2008
Posts: 36
Default

That easy huh.

Thanks!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->