In a Google Spreadsheet I have different group of cells to auto-sort ascending i.e.
- table range
a3:c16 columntosortby = 2
- table range
d18:f31 columntosortby = 5
- table range
g33:i46 columntosortby = 8
etc.
By using the following code I'm able to auto-sort the first group:
/**
* Automaticamente ordina arrivi gruppo A
*/
function onEdit(event){
var sheet = event.source.getActiveSheet();
var editedCell = sheet.getActiveCell();
var columnToSortBy = 2;
var tableRange = "a3:c16"; // Celle da ordinare.
if(editedCell.getColumn() == columnToSortBy){
var range = sheet.getRange(tableRange);
range.sort( { column : columnToSortBy, ascending: true } );
}
}
If I replicate one script for each of others groups only the last script remains active. How can I solve this?