0

I have this little code that is implemented in a bigger one:

Sub teste()
    Sheets("Reforma").Range("E10:E49").Formula = "=IF(AND(C10="",D10=""),"",IF(D10<>"",0,""))"
End Sub

however it always gives an error. I nedd help trying to figure out why. Note: my excel is in portuguese but when i go to the official microsoft webpage it says that i have to put the code in english. If i put simpler excel codes like "=c10+1" it works fine, however the one that I need does not work

I am almost certain that the formula from excel is wrong or something like this. Because I tried putting another formula and it worked fine. Does VBA have limitations regarding to formulas and multiple cells, like in my original formula when I have C10 and D10 in the same formula?

I am sorry if this was already asked, but the only other answer in Stackoverflow the problem was a parethesis and I think mine is not...

  • 3
    Try: `"=IF(AND(C10="""",D10=""""),"""",IF(D10<>"""",0,""""))"`. But it's hard to believe that this was you intent because it can be simplified with `"=IF(D10="""","""",0)"`. – VBasic2008 Apr 05 '23 at 20:00

0 Answers0