Skip to content

Instantly share code, notes, and snippets.

@erickoledadevrel
Last active April 9, 2022 16:53
Show Gist options
  • Save erickoledadevrel/0d91efe823010a6747facc0ab708f119 to your computer and use it in GitHub Desktop.
Save erickoledadevrel/0d91efe823010a6747facc0ab708f119 to your computer and use it in GitHub Desktop.
Google Apps Script code to hide a row when a checkbox is checked.
/*
* Copyright 2019 Google LLC.
* SPDX-License-Identifier: Apache-2.0
*/
var CHECKBOX_COLUMN = 'B';
function onEdit() {
var range = SpreadsheetApp.getActiveRange();
if (range.getA1Notation().split(/\d/)[0] == CHECKBOX_COLUMN &&
range.getValue() === true) {
var dv = range.getDataValidation();
if (dv && dv.getCriteriaType() == SpreadsheetApp.DataValidationCriteria.CHECKBOX) {
range.getSheet().hideRow(range);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment