0

I faced with easy routine question, but can't find solution. My task to find value of last column on concrete range.

How I try to find it?

function sales() {
  var ss1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("All data");
  var lastSalesData = ss1.getRange("C4").getNextDataCell(SpreadsheetApp.Direction.NEXT).getA1Notation(); //code will find last filling value.

  Logger.log(ss1.getRange(lastSalesData).getValues());

}

This code is available and works. But when I try to use this variable "lastSalesData" for future construction, i see mistake as

Exception: Cannot convert 'O4' to int. sales @ dashboard.gs:9

My total construction are:

function sales() {
  var ss1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("All data");
  var lastSalesData = ss1.getRange("C4").getNextDataCell(SpreadsheetApp.Direction.NEXT).getA1Notation(); 

  Logger.log(ss1.getRange(lastSalesData).getValues());


  var last12WeeksArray = [];
  last12WeeksArray = ss1.getRange(4, 3, 1, lastSalesData);
  Logger.log(last12WeeksArray);

  var last12Weeks = last12WeeksArray.slice(0, -12);
  Logger.log(last12Weeks);


}

Finally on this function I need to find last 12 values of concrete range.

I used below construction

arsonee
  • 11
  • 1

0 Answers0