Let's say A1= X+Y
Now I'd like to add +Z with a script so I end up with A1= x+y+z. I know how to copy it, or overwrite it, but not sure exactly how I would add to it with a changing formula in A1.

Some combination of getrange and copyto but also adding something to the end?

  • 2
    this seemed to work var ss = SpreadsheetApp.openById("ID"); var first = ss.getSheetByName("Name"); var gg = first.getRange('A1'); first.activate(); gg.setFormula(first.getRange('A1').getFormula() + "+Z"); – learner1234 Apr 26 '19 at 11:55
  • You should post the your solution as an answer. Ref. webapps.stackexchange.com/help/self-answer – Rubén May 14 '19 at 3:04

You could also resolve this by storing variable z into the script and then call for it like:

var variables = [2.54]
function zzz() {
  return variables[0];



or A1:


Different Example:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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