Writing a word from VBA into excel

03-16-2009, 05:15 AM

I have a logical function: 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.

03-16-2009, 05:40 AM
Change to:

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.

Colin Legg
03-16-2009, 05:42 AM
Range("AS34").FormulaR1C1 = "=if(RC[-2]<RC[-1],""Turbulent"",""Laminair"")"

03-16-2009, 09:04 AM
That easy huh.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum