Excel Vba: Double quotes in formula?

后端 未结 3 1528
误落风尘
误落风尘 2021-01-26 23:14

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, I         


        
3条回答
  •  既然无缘
    2021-01-26 23:42

    You need to double quotes for them to appear correctly in the formula

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

    should give you the following formula in the ActiveCell:

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

提交回复
热议问题