Is there any simple method to make one side of the range a variable?
function myFunction() {
var ss = SpreadsheetApp.openById("1RXJ9uR9oDV0gEL7ZyLtSi-WqFxk5Pg-7oitViHZOyf8");
SpreadsheetApp.setActiveSpreadsheet(ss);
var sheet = ss.getSheets()[0];
//This logs the value in the very last cell of this sheet
var lastRow = sheet.getLastRow();
var lastColumn = sheet.getLastColumn();
var lastCell = sheet.getRange(lastRow, lastColumn);
// add values in the last cells and calc the sum
var cellTotal = sheet.getRange(lastRow + 1, lastColumn - 1);
var cellTotalVal = sheet.getRange(lastRow + 1, lastColumn);
cellTotal.setValue('total').setFontWeight("bold");
//here I try a numorous options to get my range right
cellTotalVal.setFormula("=SUM(D1:CONCATENATE('D', lastRow))");
};
What I want to achieve here is a SUM where the first value is D1 and the last is a var named lastCell.
Thank you for any suggestions