0

I have a simple script below to get the value of the last row in column P but when I execute it does not return any value at all. The source cell has this in it 'E2&"gmail.com"', where it should return an email address:

Below is the script I created

{
  var ss = SpreadsheetApp.getActive().getSheetByName("L0 Scores");

  var LastRow = ss.getLastRow();

  var LastCol = ss.getLastColumn();

  var Range = ss.getRange(1, 1, LastRow, LastCol);

  var RangeValues = Range.getValues();

  var Admin

  for (i=LastRow; i<=LastRow; i++){

Admin = ss.getRange('P'+i).getValue();

Logger.log(Admin);
  }

}

and this is what happens when I check the log

Execution Log

Thanks in advance

1 Answers1

1
function valueInLastRowColP() {
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getSheetByName("L0 Scores");
  var rg=sh.getRange(sh.getLastRow(),16);
  return rg.getValue();
}
Cooper
  • 59,616
  • 6
  • 23
  • 54
  • 2
    While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – Yogurt Feb 26 '20 at 02:51
  • I was doing an MailApp function and was getting a No recipient error. Tried to check the log an it was not returning the value in the cell. I'll try both ways the one provided by TheMaster and urself. Thanks in advance – Mai Villanueva Feb 26 '20 at 20:05