"The coordinates of the range are outside the dimensions of the sheet" error when sorting
Solution 1:
It's very likely that the error occurs on the line
var range = sheet.getRange(2, 1, sheet.getLastRow(), sheet.getLastColumn());
It's very likely that the solution is to change it by
var range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());
The above because the range start on row 2 and because it's very likely that sheet has content on its last row.
Related
- Google Sheets Script getLastRow() not returning all values
- Need help debugging Google Apps Script code intended to update hundreds of files in Google Drive