Skip to content

Instantly share code, notes, and snippets.

@lordlycastle
Forked from erickoledadevrel/checkAndHide.gs
Created April 12, 2021 20:30
Show Gist options
  • Save lordlycastle/e4a48a58cff9d534afd52c29226b35ea to your computer and use it in GitHub Desktop.
Save lordlycastle/e4a48a58cff9d534afd52c29226b35ea 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