I have on a google spreadsheet on the sheet "SUIVI ANIM", a column Y whose each cell contains from line 5, a drop-down menu. Then I have in column Z a small "x". I would like that when in column Y, it is "Submit LEAD" which is selected that automatically the small "x" of column Z is erased. For example, if "Submit LEAD" in Y3 then Z3 is empty. If "Submit LEAD" in Y4 then Z4 empties etc.
I searched and found this script:
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
// identify the range and values to watch and clear
var watchCol = 25; // Column Y
var watchValue = "Submit LEAD";
var clearCol = 26; // Column Z
//
// Logger.log("DEBUG: the column = "+e.range.columnStart+", and the value = "+e.value)
if (e.range.columnStart === watchCol && e.value === watchValue) {
// Logger.log("DEBUG: the conditions were met");
sheet.getRange(e.range.rowStart, clearCol).clearContent()
}
return false;
}
But it doesn't work and the debug tells me it's wrong from the line: if (e.range.columnStart === watchCol && e.value === watchValue) {
I'm new to scripting and I'm French so sorry if I'm not very clear.
Thanks for any help you could give me. émilie
function onEdit(e) {
var sh = e.range.getSheet();
if (e.range.columnStart == 25 && e.value == "Submit LEAD") {
sheet.getRange(e.range.rowStart, 26).clearContent();
}
}
Normally people put a sheet name in the conditional so that it only runs on selected sheets.