View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Turtle_Todd[_2_] Turtle_Todd[_2_] is offline
external usenet poster
 
Posts: 1
Default Using Text in a Formula or FormulaR1C1 property

works great, thanks

"Gary''s Student" wrote:

Double up the double quotes:

Sub dural()
s = "=IF(A1=""apples"", ""yes"",""no"")"
Range("B1").Formula = s
End Sub

--
Gary''s Student - gsnu200840


"Turtle_Todd" wrote:

I want to use a logical if statement checking a text word in a formula
statement.

I want programmatically to create the cell
=IF(A1="apples","Yes","No")

However, when I enter
Range("B1").Formula="=IF(A1="apples","Yes","No")"

in VB the quotes mess this all up. The single quotes don't work either
Range("B1").Formula="=IF(A1='apples','Yes','No')"

Any ideas?