Skip to main content
added 125 characters in body
Source Link
user555121
user555121

I'm not sure when they did it, but they've added this now. 

Use class DataValidationBuilder's requireCheckbox()requireCheckbox() method. Example:

function setCheckboxes() { // Assumes there's only one sheet var sheet = SpreadsheetApp.getActiveSheet(); // This represents ALL the data var dataRange = sheet.getDataRange(); /* Get checkbox range from sheet data range. Assumes checkboxes are on the left-most column */ var dataRangeRow = dataRange.getRow(); var dataRangeColumn = dataRange.getColumn(); var dataRangeLastRow = dataRange.getLastRow(); var checkboxRange = sheet.getRange( dataRangeRow, dataRangeColumn, dataRangeLastRow ); var enforceCheckbox = SpreadsheetApp.newDataValidation(); enforceCheckbox.requireCheckbox(); enforceCheckbox.setAllowInvalid(false); enforceCheckbox.build(); checkboxRange.setDataValidation(enforceCheckbox); } 

I'm not sure when they did it, but they've added this now. Use class DataValidationBuilder's requireCheckbox() method. Example:

function setCheckboxes() { // Assumes there's only one sheet var sheet = SpreadsheetApp.getActiveSheet(); // This represents ALL the data var dataRange = sheet.getDataRange(); /* Get checkbox range from sheet data range. Assumes checkboxes are on the left-most column */ var dataRangeRow = dataRange.getRow(); var dataRangeColumn = dataRange.getColumn(); var dataRangeLastRow = dataRange.getLastRow(); var checkboxRange = sheet.getRange( dataRangeRow, dataRangeColumn, dataRangeLastRow ); var enforceCheckbox = SpreadsheetApp.newDataValidation(); enforceCheckbox.requireCheckbox(); enforceCheckbox.setAllowInvalid(false); enforceCheckbox.build(); checkboxRange.setDataValidation(enforceCheckbox); } 

I'm not sure when they did it, but they've added this now. 

Use class DataValidationBuilder's requireCheckbox() method. Example:

function setCheckboxes() { // Assumes there's only one sheet var sheet = SpreadsheetApp.getActiveSheet(); // This represents ALL the data var dataRange = sheet.getDataRange(); /* Get checkbox range from sheet data range. Assumes checkboxes are on the left-most column */ var dataRangeRow = dataRange.getRow(); var dataRangeColumn = dataRange.getColumn(); var dataRangeLastRow = dataRange.getLastRow(); var checkboxRange = sheet.getRange( dataRangeRow, dataRangeColumn, dataRangeLastRow ); var enforceCheckbox = SpreadsheetApp.newDataValidation(); enforceCheckbox.requireCheckbox(); enforceCheckbox.setAllowInvalid(false); enforceCheckbox.build(); checkboxRange.setDataValidation(enforceCheckbox); } 
Minor formatting
Source Link
Stephen Rauch
  • 50.1k
  • 32
  • 118
  • 143

I'm not sure when they did it, but they've added this now. Use class DataValidationBuilder's requireCheckbox()DataValidationBuilder's requireCheckbox() method. Example:

function setCheckboxes() { // Assumes there's only one sheet var sheet = SpreadsheetApp.getActiveSheet(); // This represents ALL the data var dataRange = sheet.getDataRange(); /* Get checkbox range from sheet data range. Assumes checkboxes are on the left-most column */ var dataRangeRow = dataRange.getRow(); var dataRangeColumn = dataRange.getColumn(); var dataRangeLastRow = dataRange.getLastRow(); var checkboxRange = sheet.getRange( dataRangeRow, dataRangeColumn, dataRangeLastRow ); var enforceCheckbox = SpreadsheetApp.newDataValidation(); enforceCheckbox.requireCheckbox(); enforceCheckbox.setAllowInvalid(false); enforceCheckbox.build(); checkboxRange.setDataValidation(enforceCheckbox); } 

I'm not sure when they did it, but they've added this now. Use class DataValidationBuilder's requireCheckbox() method. Example:

function setCheckboxes() { // Assumes there's only one sheet var sheet = SpreadsheetApp.getActiveSheet(); // This represents ALL the data var dataRange = sheet.getDataRange(); /* Get checkbox range from sheet data range. Assumes checkboxes are on the left-most column */ var dataRangeRow = dataRange.getRow(); var dataRangeColumn = dataRange.getColumn(); var dataRangeLastRow = dataRange.getLastRow(); var checkboxRange = sheet.getRange( dataRangeRow, dataRangeColumn, dataRangeLastRow ); var enforceCheckbox = SpreadsheetApp.newDataValidation(); enforceCheckbox.requireCheckbox(); enforceCheckbox.setAllowInvalid(false); enforceCheckbox.build(); checkboxRange.setDataValidation(enforceCheckbox); } 

I'm not sure when they did it, but they've added this now. Use class DataValidationBuilder's requireCheckbox() method. Example:

function setCheckboxes() { // Assumes there's only one sheet var sheet = SpreadsheetApp.getActiveSheet(); // This represents ALL the data var dataRange = sheet.getDataRange(); /* Get checkbox range from sheet data range. Assumes checkboxes are on the left-most column */ var dataRangeRow = dataRange.getRow(); var dataRangeColumn = dataRange.getColumn(); var dataRangeLastRow = dataRange.getLastRow(); var checkboxRange = sheet.getRange( dataRangeRow, dataRangeColumn, dataRangeLastRow ); var enforceCheckbox = SpreadsheetApp.newDataValidation(); enforceCheckbox.requireCheckbox(); enforceCheckbox.setAllowInvalid(false); enforceCheckbox.build(); checkboxRange.setDataValidation(enforceCheckbox); } 
Source Link

I'm not sure when they did it, but they've added this now. Use class DataValidationBuilder's requireCheckbox() method. Example:

function setCheckboxes() { // Assumes there's only one sheet var sheet = SpreadsheetApp.getActiveSheet(); // This represents ALL the data var dataRange = sheet.getDataRange(); /* Get checkbox range from sheet data range. Assumes checkboxes are on the left-most column */ var dataRangeRow = dataRange.getRow(); var dataRangeColumn = dataRange.getColumn(); var dataRangeLastRow = dataRange.getLastRow(); var checkboxRange = sheet.getRange( dataRangeRow, dataRangeColumn, dataRangeLastRow ); var enforceCheckbox = SpreadsheetApp.newDataValidation(); enforceCheckbox.requireCheckbox(); enforceCheckbox.setAllowInvalid(false); enforceCheckbox.build(); checkboxRange.setDataValidation(enforceCheckbox); }