Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save phillypb/385dc06b33987bc0180715ab7aac0da0 to your computer and use it in GitHub Desktop.
Save phillypb/385dc06b33987bc0180715ab7aac0da0 to your computer and use it in GitHub Desktop.
/*
This Function is designed to clear the adjacent cell to the right of the one
that has just been edited - so long as it is within the column we specify
(so only edits in column 2 here).
*/
function onEdit(e) {
// get edited cell from the event object
var cell = e.range;
// get edited cell column from the event object
var column = cell.getColumn();
Logger.log('Column is: ' + column);
// get edited cell row from the event object
var row = cell.getRow();
Logger.log('Row is: ' + row);
// get spreadsheet from the event object
var source = e.source;
if (column == 2) {
// clear adjacent cell value
var ss = source.getSheetByName('Clear cell');
ss.getRange(row, column+1).clear();
}
else {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment