0

Im trying to add a formula to a cell with VBA, however the formula includes a conditional that checks the text of the day of the week, what would be the correct syntaxis? It seems to be confusing the semicolons of text with the end of formula.

Code error

I tried applying

Range("AC7").Formula("=IF(OR(A7="l",A7="m",A7="mi",A7="j",A7="v"),SUM(D7:I7),IF(A7="s",SUM(D7:K7),SUM(D7:U7)))")

And I was expecting it just to put the formula in cell AC7 but it marks an error qhen it get to the "l".

BigBen
  • 46,229
  • 7
  • 24
  • 40
  • 3
    `Range("AC7").Formula = "=IF(OR(A7=""l"",A7=""m"",A7=""mi"",A7=""j"",A7=""v""),SUM(D7:I7),IF(A7=""s"", SUM(D7:K7),SUM(D7:U7)))"` – Scott Craner Nov 15 '22 at 16:22

0 Answers0