Dima Petrov
Dima Petrov

Reputation: 5

How to Convert TRUE/FALSE to Checkboxes in Google Sheets?

How to Convert TRUE/FALSE to Checkboxes in Google Sheets?

enter image description here

Upvotes: 0

Views: 7008

Answers (2)

Dimension Datacraft
Dimension Datacraft

Reputation: 136

As a no code solution you can simply highlight the range that has 'true' and 'false' in it and go to 'insert' on the toolbar and hit 'checkbox'. This will add the checkboxes in that range while honoring the true and false values as indicated.

Upvotes: 1

NightEye
NightEye

Reputation: 11214

This should work. Just note that blank cells will convert to unchecked checkbox if included in the range. This should work on the sample sheet you provided. This will not convert anything to checkbox if the cells are not containing blank, true or false.

function generateCheckBox() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var lastRow = sheet.getLastRow();
  var column = sheet.getRange('A2:B' + lastRow);

  var validateCheckBox = SpreadsheetApp.newDataValidation();
  validateCheckBox.requireCheckbox();
  validateCheckBox.setAllowInvalid(false);
  validateCheckBox.build();

  column.setDataValidation(validateCheckBox);
}

If you have any questions/clarification, feel free to comment below.

Upvotes: 3

Related Questions