VBA Excel – Using Double Quotes in Formulas

excelvba

I don't know the syntax for handling double quotation marks within a formula.

Here is my code:

ActiveCell.Formula = "=IF($W9="A",1,IF($W9="B",2, IF($W9="C",3,0))))"

Any help is greatly appreciated.

Best Answer

You need to change the formula to

ActiveCell.Formula = "=IF($W9=""A"",1,IF($W9=""B"",2, IF($W9=""C"",3,0)))"

So, first you need to double quote and in your case you also need to count the number of "(" and ")"

Related Question