I have a running onEdit script that makes a 2 timestamps on Column B (Date) and C (Time), when something is input in Column A.
My end goal is to make a scrip that, if an Input is done Column A, a subtraction of (Ex: Row 3 - Row 2) in timevalue format in Column D happens , if Column B is the same date, otherwise empty.
I made a formula for this, But I would rather have as script to run everything automatically.
This is the scrip I'm running right now:
function onEdit(e) {
var row = e.range.getRow();
var col = e.range.getColumn();
if(col === 1 && row > 1 && e.source.getActiveSheet().getName() === "Raul") {
if(e.source.getActiveSheet().getRange(row,2).getValue() == ""){
e.source.getActiveSheet().getRange(row,2).setValue(new Date());
if(e.source.getActiveSheet().getRange(row,3).getValue() == ""){
e.source.getActiveSheet().getRange(row,3).setValue(new Date());
}
}
}
}
The formula I have currently for Column D is:
=IF(LEFT(B3;10)=Left(B2;10);Timevalue(C3-C2);"")
I would like to have this formula integrated in the script somehow, if possible.