MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Formula with conditional text

  Asked By: Grant    Date: Jan 01    Category: MS Office    Views: 1753

I wish to enter a formula into a cell using VB.
The formula is:-
ActiveCell.Formula = "=If(MoDNonComp="No",0,1)"
When I run the code I get a "1004: Application-defined or Object-
defined error".
I think the problem is the inverted commas of the "No" part of the
How do I get around this problem ?



2 Answers Found

Answer #1    Answered By: Shaun Thomas     Answered On: Jan 01

the way i handle that is double quotes... or try using ' instead of double

Answer #2    Answered By: Akins Massri     Answered On: Jan 01

Double the inverted commas.

ActiveCell.Formula = "=If(MoDNonComp=""No"",0,1)"

Didn't find what you were looking for? Find more on Formula with conditional text Or get search suggestion and latest updates.