P
P
PiShim2020-12-25 09:33:55
Google Sheets
PiShim, 2020-12-25 09:33:55

Automatic creation of checkbox in google sheets, how to do?

I can't think of a script, macro, or formula to automatically create a checkbox. The bottom line: for example, cell A1 is empty, and as soon as any value appears in it, an empty checkbox appears in cell B1. Please tell me how to do it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksei Shebanits, 2020-12-25
@PiShim

function onEdit(e) {
  let sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  let row = e.range.getRow();
  let column = e.range.getColumn();
  let value = e.source.getActiveSheet().getRange(row, 1).getValue();
  let checkbox = SpreadsheetApp.newDataValidation().requireCheckbox().setAllowInvalid(false).build();

  if (column == 1 && value !== "") {
    sheet.getRange(row, 2).setDataValidation(checkbox).setValue(false);
  }

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question