I have the below script running to sort column E in an ascending order. Each row is a different task and column E is the deadline. I have another piece of script running which deletes the deadline in column E once 'Complete' has been selected in another column. Hence, completed tasks will show empty cells in column E.
The deadlines are currently sorting from closest to furthest away, however E cells that are now empty are not moving to the bottom. I am a Scripts newbie and cannot see the issue. Any help to resolve this issue would be much appreciated.
function onEdit(event){var ss = SpreadsheetApp.getActiveSpreadsheet();var sh0 = ss.getSheetByName("2020"); var sheet = ss.getActiveSheet(); var editedCell = sheet.getActiveCell(); var columnToSortBy = 5; var tableRange = "A2:I998"; if(editedCell.getColumn() == columnToSortBy){ var range = sheet.getRange(tableRange); range.sort( { column : columnToSortBy, ascending: true } ); } }