Skip to content

Instantly share code, notes, and snippets.

@adamcbrewer
Created February 1, 2014 14:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adamcbrewer/8753190 to your computer and use it in GitHub Desktop.
Save adamcbrewer/8753190 to your computer and use it in GitHub Desktop.
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