Instantly share code, notes, and snippets.

Embed
What would you like to do?
GS: Automatically sorts the 1st column (not the header row) Ascending.
/**
* Automatically sorts the 1st column (not the header row) Ascending.
*/
function onEdit(event){
var sheet = event.source.getActiveSheet();
var editedCell = sheet.getActiveCell();
var columnToSortBy = 1;
var tableRange = "A4:Z99"; // What to sort.
if(editedCell.getColumn() == columnToSortBy){
var range = sheet.getRange(tableRange);
range.sort( { column : columnToSortBy, ascending: false } );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment