I am trying to automatically sort a certain range of my sheet onEdit
in a way that on the top is an empty cell and towards the bottom are the oldest entries.
I have gotten this code from here and tried to modify it for my needs:
function onEdit(e)
{
var sheet = ss.getActiveSheet();
if( sheet != ss.getSheetByName('cover sheet'))
{
var editRange = { // B4:J6
top: 29,
bottom: sheet.getLastRow()+1,
left: 4,
right: 11
};
// Exit if we're out of range
var thisRow = e.range.getRow();
if (thisRow < editRange.top || thisRow > editRange.bottom) return;
var thisCol = e.range.getColumn();
if (thisCol < editRange.left || thisCol > editRange.right) return;
// We're in range; timestamp the edit
var ss = e.range.getSheet();
ss.getRange(editRange).sort({column: 1, ascending: true});
}
}
But that does not work. Any Ideas? Here is the link to a sample sheet.
Regards