title: "The coordinates of the range are outside the dimensions of the sheet" error when sorting
body: <p>I am trying to create a script to sort a table on the current active sheet/tab but I am getting an error that I could not identify. I keep getting <code>The coordinates of the range are outside the dimensions of the sheet.</code>. My table has data in them from columnA to columnQ. Data in columnA are identification numbers and columnB to columnQ contain formulas. What am I doing wrong with my script?</p>
  
  <pre><code>var sortFirst = 7; //index of column to be sorted by; 1 = column A, 2 = column B, etc.
    var sortFirstAsc = true; //Set to false to sort descending
  
    var sortSecond = 8;
    var sortSecondAsc = true;
  
    var sortThird = 9;
    var sortThirdAsc = true;
  
    var activeSheet = SpreadsheetApp.getActiveSheet();
    var sheetName = activeSheet.getSheetName(); //name of sheet to be sorted
    var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);
    var range = sheet.getRange(2, 1, sheet.getLastRow(), sheet.getLastColumn());
    range.sort([{column: sortFirst, ascending: sortFirstAsc}, {column: sortSecond, ascending: sortSecondAsc}, {column: sortThird, ascending: sortThirdAsc}]);
  </code></pre>