Search code examples
google-sheetsgoogle-apps-script

Incorrect result of iferror formula via Apps Script


One of my line in google apps script function is next

mnmaSheet.getRange(9,22).setFormulaR1C1("=IFERROR(MATCH(R[0]C[-1!D:D,0);-1)")

However, after running the script result is incorrect because I always receive -1 even if the searched value is present in the sheet "Довідник".

I tried to write two brackets from both sides of sheet's name (''Довідник''), however I receive error. In addition, I tried to write codes for updating cells however it didn't work too.


Solution

  • Changing setFormulaR1C1(formula) to setFormula(formula) works since The given formula must be in R1C1 notation. for it to work.

    The formula =IFERROR(MATCH(R[0]C[-1!D:D,0);-1) has arguments that are in A1 notation, which is why it was returning -1.