Home > Software engineering >  Google Script - Increment the data range every time script is run using using Apps script on Google
Google Script - Increment the data range every time script is run using using Apps script on Google

Time:07-20

I'm trying to create a list from one cell that is consistently updated in google sheets.

I have the following code inside my function.

 var app = SpreadsheetApp;

var tS = app.getActiveSpreadsheet().getSheetByName("Dashboard");

var tempNum =  tS.getRange(18,11).getValue();

var ttS = app.getActiveSpreadsheet().getSheetByName("GraphData");

var ud = ttS.getRange('A1').setValue(tempNum);

How do I add the value stored in tempNum to a new row every time the script is executed?

I will then trigger the script once per day to set the new value into the row below and then create a graph from said values.

Thanks in advance, let me know if any more information is needed.

CodePudding user response:

To append the value stored in tempNum to a new row at the end of the GraphData sheet every time the script is executed, use Sheet.appendRow(), like this:

  ttS.appendRow([tempNum]);

See Apps Script at Stack Overflow.

  • Related