Sam Chats
Sam Chats

Reputation: 2321

Google Apps Script setFormulasR1C1 gives formula parse error

I'm using Google Apps Script to copy formulas from one row to another; however when I call setFormulasR1C1() on the new row with oldRow.getFormulasR1C1() passed as argument, the formulas do get copied as expected but I get a Formula parse error back on the sheet.

Here's the relevant code snippet:

var referenceRowFormulasR1C1 = referenceRow.getFormulasR1C1();
var currentRow = sh.getRange("A"+rowNum+":"+rowNum);
currentRow.setFormulasR1C1(referenceRowFormulasR1C1);

Back in the sheets, I get the following error:

screenshot of error

Formulae of row 82 were copied from row 81. The formula for B81 looks like this, and works fine (so does the formula for B83):

=VLOOKUP(F81,'Transport & Guide Languages & Training'!$A$2:$I$100,5,FALSE)

Upvotes: 2

Views: 843

Answers (1)

Sam Chats
Sam Chats

Reputation: 2321

I just realized, the problem was empty values in referenced cells. For example, as soon as I filled cell F82, the formula for B82 fell in place and returned the correct value. Similarly, other formulae started giving correct values as soon as I filled other (empty) referenced cells.

Upvotes: 3

Related Questions