title: Google spreadsheet "Cannot call method "getRange" of null"
body: <p>I'd like to generate a unique ID in column A if column B has changed in every row from the 6th. It would be enough to use a number from 1 to X as ID but it should no change after moving de row. Yet I'm getting an error continuously "Cannot call method "getRange" of null."</p>
  
  <pre><code>function onEdit() {
   var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('ScriptTest');
   var column0 = sheet.getRange(6, 2, sheet.getLastRow()-6, 1);
   var oValues = column0.getValues();
  
   if (oValues[sheet.getLastRow()][0] == '') {
     sheet.getRange(sheet.getLastRow(), 1, 1, 1).setValue(ContentService.createTextOutput(sheet.getLastRow()-6));
   }  
  }
  </code></pre>