0

I am struggling with some strange problem when working with excel vba which im using to paste formula inside some cell.

So I've got a VBA code that loops through some worksheets in my workbook and based on it values it is pasting formulas to cell. First of them is formula Like =COUNTA(Station_Tabular!D6:D60) where station_tabular is sheetName and with this formula everything is fine. But when i try to paste =COUNTIF(Station_Tabular!D6:D60;Introduction!C43) i'm getting Application-defined or object defined error and what is interesting when i inject the formula using vba without = sign(So, it is normal text) and later, manually add the = sign at the beginning, the formula is working good.

So does somebody know how can i deal with this kind of problem? Honestly it's driving me crazy, because i tried many workarounds, like e.g later add in vba code the equal sign but every time i'm getting the same error. It is very important to me to find a way to prepare this formula using vba only.

  • If you're using `.Formula = "=COUNTIF(Station_Tabular!D6:D60;Introduction!C43)"`, you need to use `,` as the separator instead of `;`. See the linked duplicate for a thorough discussion. – BigBen Jul 08 '20 at 13:35
  • in VBA, which is EN-US centric, one must use `,` instead of `;` when using `.Formula` – Scott Craner Jul 08 '20 at 13:35
  • Thanks a lot Guys, i can't believe that solution was so simple. – Galinowsky Jul 08 '20 at 13:54
  • 1
    Or you could use `.FormulaLocal` and not worry about the EN-US centricity. – CLR Jul 08 '20 at 14:19

0 Answers0