In my else
statement below, if a cell in column G is blank I want to clear the contents (the timestamp) of another cell in column F using the event function onEdit()
. However, after testing the code and deleting values, the cell is no longer recognized as blank when comparing e.value
to a blank cell using e.value == ""
. What can I use in the conditional that determines if a cell is truly blank after having deleted a previous value from the cell?
function onEdit(e)
{
var ss = e.source.getActiveSheet();
var row = e.range.getRow(); //row the user has edited
var rowHeader = 1;
var colStart = 7 //Column that contains Departure outcome values
var colToUpdate = 6; //Check out timestamp column to update if user edits a cell in Departure column
if(e.range.rowStart > rowHeader && e.range.columnStart === colStart && (e.value !="" || !0))
{
ss.getRange(row,colToUpdate).setValue(new Date()); // place time stamp in Check Out column
}
else if(e.range.rowStart > rowHeader && e.range.columnStart === colStart && e.value == "")
{
ss.getRange(row,colToUpdate).clearContent();
}
}
Link to spreadsheet: https://docs.google.com/spreadsheets/d/11vTNBa-YVjyACKPjWDO97Zs397mJrNHnXPDnpGDoVGQ/edit?usp=sharing