I am looking for a script that will clear cell(s) when the value of another cell changes or is equal to ("X").
In the attachment I would like when Column "G" gets checked marked (TRUE), then Columns "D"& "E" become cleared (or no value) according to the respective row that was checked (TRUE).
For Example:
When "G3" is checked (TRUE), then D3 & E3 are cleared. As you can see that it is important that both columns get cleared out as it affects Columns "E", "F", and "H" which all include very important information that needs to be automatically updated according to Column "G" to remove as much human error as possible.
I have done some research on my own searching through this site, other sites and forums, and google support, etc. There was one that was close to this that I wanted, but it would "hide" the row, which I don't want and supposedly it would clear a cell but I couldn't get that to work. i attempted to make my own edits but I do not have experience enough to troubleshoot.
Here is something that I found and couldn't troubleshoot:
function onEdit(e) {
var sh = e.source.getActiveSheet();
if (sh.getName() !== 'Sheet2' || e.range.columnStart !== 3 || e.range.rowStart < 2 || e.value !== 'No') return;
e.range.offset(0, 3).clearContent()
sh.hideRows(e.range.rowStart)
}
Then change the highlighted text to the name of the sheet/tab you want the script to work on. Finally close the script editor (!) and navigate to that sheet. Try entering 'No' in col C and see what happens.
I edited it to be:
function onEdit(e) {
var sh = e.source.getActiveSheet();
if (sh.getName() !== 'Main' || e.range.columnStart !== 7 || e.range.rowStart < 2 || e.value !== 'FALSE') return;
e.range.offset(0, 3).clearContent()
sh.hideRows(e.range.rowStart)
}
I can get it to hide the row (which I don't want), but I can't get it to clear a cell, let alone two of them.
Here is what I have from Raymond Tran's answer (good workaround for now):