0

I have a google sheets app script which fetch data from webpage and enter it in google spreadsheet.

Among others, when executed to the end, script fetch date written on the webpage and enter it in column A. I want that script fetch all data from the webpage only if date on the webpage (var date) is different from last date already entered in spreadsheet (var lastdate).

How to make var lastdate as value from last cell of column A?

Thanks in advance.

regularSheetName = "Regular method";
link = "http://...";

function checkDate(){

var page = UrlFetchApp.fetch(link).getContentText();

var ss = SpreadsheetApp.getActiveSpreadsheet();

var regularSheet = ss.getSheetByName(regularSheetName);

var Avals = ss.getRange("A1:A").getValues();
var Alast = Avals.filter(String).length;

var date = page.match(/results of (.*?) - with/m)[1];

var lastdate = regularSheet.getRange(Alast).getValue();
     if(date != lastdate){

  return SpreadsheetApp.getUi().alert("It's different");

}

Error:

Exception: Range not found

TheMaster
  • 45,448
  • 6
  • 62
  • 85
  • Put error messages in your question.. What are the valid `getRange()` parameters? `regularSheet.getRange(Alast).getValue();`. `Alast` is of `number` type. See https://stackoverflow.com/questions/11334296/how-to-set-the-value-to-a-cell-in-google-sheets-using-apps-script – TheMaster Oct 09 '20 at 12:59
  • 1
    I've solved this problem. I've made mistake in row: var lastdate = regularSheet.getRange(Alast).getValue(); and it should look like this: var lastdate = regularSheet.getRange(Alast, 1).getValue(); Thank you for your assistance. – user3316048 Oct 09 '20 at 19:37

0 Answers0