3

I'm trying to insert a formula into a cell using VBA.
This one code works just fine:

Range("C6").FormulaLocal = "=SI(AI6<>"""";""Dictaminado"";SI(O(AB6<>"""";AC6<>"""");""En Dictamen"";SI(AA6<>"""";""Recibido"";""Pend. Pack"")))"

The problem is with this other code:

Range("D6").FormulaLocal = "=SI(O(E6:I6="""";K6="""";N6:O6="""";Q6:S6="""";Y6="""";AA6:AC6="""";AE6:AF6="""";AH6:AK6="""");""Miss. Info"";""Complete"")"

In Excel an @ appears in front of every range in the formula like this:

=SI(O(E6="";K6="";@N6:O6="";@Q6:S6="";Y6="";@AA6:AC6="";@AE6:AF6="";@AH6:AK6="");"Miss. Info";"Complete")

And it throws a #VALUE error. Can someone explain why is this happening and how to avoid it?

1
  • Appears to be an array formula. So FormulaArray? But don't forget that wont take local written formats...
    – JvdV
    Commented Apr 17, 2020 at 10:50

1 Answer 1

1

Thanks @JvdV for your comment!

Appears to be an array formula. So FormulaArray? But don't forget that wont take local written formats...

I solved it doing this:

Range("D6").FormulaLocal = [here goes the formula]
Range("D6").FormulaArray = Range("D6").Formula

Not the answer you're looking for? Browse other questions tagged or ask your own question.