Trying to figure out how copy and paste a formula using Google Script in google sheets. When I use the getFormula and setFormula it does copy the formula but it keeps the same range, it does not dynamically update the range like it normally does when you use the spreadsheet without a script. Wondering what I am doing wrong... here is my code

     var source = formulaSheet.getRange(row+1,col-1).getFormula();
     var target = formulaSheet.getRange(row+1,col);

1 Answer 1


Use R1C1 notation instead of A1 as the first allows to use relative coordinates. For this you could use getformular1c1 and/or getformulasr1c1 and the corresponding "set" versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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