I'm trying to write an onEdit
script where I modify values on rows in Column C, and have corresponding rows in Column D & E updated with the last non empty values from Columns A & B, see screenshot:
I'm mainly having problems trying to figure the last non empty value, I feel like some sort of reverse FOR that counts backwards from the activeCell()
value and checks for IFBLANK until a non blank value is found? See the script is prepared:
function onEdit() {
var s = SpreadsheetApp.getActiveSpreadsheet();
var r = s.getActiveCell();
var sh = s.getActiveSheet();
if( r.getColumn() == 3 ) {
var activerow = r.getRow();
var lasttime = ???
var lastitem = ???
s.getRange('G' + activerow.toString()).setValue(lasttime);
s.getRange('H' + activerow.toString()).setValue(lastitem);
}
}