Quote marks delineate String constants (text) in
VB, so the internal quote
marks are confusing the
VB compiler.
VB does provide a mechanism to include
quote marks within a String... double them up. So, wherever you need a quote
mark inside a String constant, use two quote marks instead of the one you
would normally use.
Range("c4").Formula = "=IF(C4 = 5,""ACTIVATED"",""NOT ACTIVATED"")"
Note that the outer quote marks are not doubled up... they are the ones that
delineate the String constant; it is only quote marks within them that need
to be doubled up in order to be interpreted as a quote mark character and
not a String delineater.
Rick
"anon" wrote in message
...
Hi,
I want to put this formula into a cell via VBA;
=IF(C4 = 5,"ACTIVATED","NOT ACTIVATED")
However this would mean the code would be;
range("c4").formula = "=IF(C4 = 5,"ACTIVATED","NOT ACTIVATED")"
which will cause me errors because of the "" enclosed in the formula.
I'd appreciate if anyone could clear this up for me. Thanks,