Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9706

Google Script Sort Column Ascending Order with Blank Cells at Bottom

$
0
0

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 } );  }  }

Viewing all articles
Browse latest Browse all 9706

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>