I'm trying to create a spreadsheet for my team, and using this script I am only getting one of the on edit if statements to function. How can I fix this? I'm not very versed in script writing.
function onEdit(e) {
const sh=e.range.getSheet();
if(sh.getName()=='Confirmation Check' && e.range.columnStart==8 && e.value=='TRUE') {
var resp=SpreadsheetApp.getUi().alert('REMINDER: Did you update the P.5 with the initiation date?', SpreadsheetApp.getUi().ButtonSet.YES_NO);
if(resp==SpreadsheetApp.getUi().Button.YES) {
if(e.range.columnStart >8) return;
e.source.getActiveSheet().getRange(e.range.rowStart,9).setValue(new Date());
return;
if(sh.getName()=='Confirmation Check' && e.range.columnStart==6 && e.value=='TRUE') {
var resp=SpreadsheetApp.getUi().alert('REMINDER: Did you update the P.5 with the authoritzation date?', SpreadsheetApp.getUi().ButtonSet.YES_NO);
if(resp==SpreadsheetApp.getUi().Button.YES) {
if(e.range.columnStart >6) return;
e.source.getActiveSheet().getRange(e.range.rowStart,7).setValue(new Date());
return;
}
}
}
}
}
onEdit
should insert the date in the adjacent cell if Column 6 or 8 = true on sheet = "Confirmation Check" AND a response of "Yes" to an alert; the problem is that it's working for Column 8 but not for Column 6." Don't leave it so that a volunteer must read your script and try and make sense of it.