I have a data-set which I would like to have sorted with first column 6 and then column 7.
From this post: How can I make some data on a Google Sheets auto-sorting? I have gotten ideas about making a script.
I have made it so far it is sorting by column 6 but NOT column 7.
Any idea what I do wrong?
function myFunction() {
}
function onEdit(event){
var sheet = event.source.getActiveSheet();
var editedCell = sheet.getActiveCell();
var columnToSortBy = 6;
var tableRange = "A2:U";
if(editedCell.getColumn() == columnToSortBy){
var range = sheet.getRange(tableRange);
range.sort([{column: 6, ascending: true}, {column: 7, ascending: true}]);
}
}