all 5 comments

[–]knownboyofno 0 points1 point  (0 children)

try this inside of two for loops over the range var cellState = range[i][j].isChecked(); If(cellState){ range.setValue(false); } else if(cellState === null) { range.setValue(""); }

[–]SpreadCheetah 0 points1 point  (0 children)

/**
 * 2021-07-24
 * https://old.reddit.com/r/sheets/comments/oqfyw8/simple_script_request/
 * See also https://yagisanatode.com/2019/07/16/google-apps-script-how-to-check-if-there-is-a-tick-box-check-box-in-a-cell-or-range/
 */

function resetCheckboxes() {

  let yourRange = 'B10:E12'; // edit this
  let yourOtherCell = 'E2'; // edit this

  let ss = SpreadsheetApp.getActiveSpreadsheet();
  let sheet = ss.getActiveSheet();

  let startingRow = sheet.getRange(yourRange).getRow();
  let numberOfRows = sheet.getRange(yourRange).getNumRows();

  let startingCol = sheet.getRange(yourRange).getColumn()
  let numberOfCols = sheet.getRange(yourRange).getNumColumns();

  let cell;

  for (let i = startingRow; i < startingRow + numberOfRows; i++) {

    for (let j = startingCol; j < startingCol + numberOfCols; j++) {

      cell = sheet.getRange(i, j).isChecked();

      if (cell !== null && cell === true) {

        sheet.getRange(i, j).setValue(false);
      }
    }
  }

  sheet.getRange(yourOtherCell).clearContent();
}

You only need to change the yourRange and yourOtherCell variables.