iamthe202
iamthe202

Reputation: 39

Checkbox triggered clearcontent Script then automatically unchecking it immediately

I'm looking for clearing a range with checking a checkbox, then having the script to uncheck it.

This is what I tried so far, but besides the fact it's looping, I don't know how to force the TRUE to FALSE automatically whenever a FALSE becomes a TRUE.

function onEdit(e) {
  var aCell = e.source.getActiveCell(), col = aCell.getColumn(); 
  if(col == 2) { 
    var app = SpreadsheetApp;
    var activeSheet = app.getActiveSpreadsheet().getActiveSheet();
activeSheet.getRange("D4:D6").clearContent()
  }}

Upvotes: 0

Views: 57

Answers (1)

TheMaster
TheMaster

Reputation: 50472

Test the range using isChecked():

if(aCell.isChecked()) aCell.uncheck();

Upvotes: 1

Related Questions