Home > OS >  Google Sheets Hiding Rows using checkboxes Apps Script
Google Sheets Hiding Rows using checkboxes Apps Script

Time:03-16

Sort of Newbie so please be kind.

I have been working on this code for hours and I have been making progress ... I think lol ... but I now seem to be stuck.

You will see in the photo enter image description here

CodePudding user response:

Hiding Rows in column B if they are checkboxes

The function assumes a one row and one column offset for the checkboxes in columnB from the checkboxes in columnA and the hides rows as long as it finds checkboxes in the rows. When there is not a checkbox it stops

function onMyEdit(e) {
  const sh = e.range.getSheet();
  if (sh.getName() == 'Sheet0' && e.range.columnStart == 1 && e.value == "TRUE") {
   if(e.range.offset(1, 1).getDataValidation().getCriteriaType() == "CHECKBOX") {
     let r = e.range.offset(1,1).getRow();
     let i = 0;
     do{
       sh.hideRows(r   i  );
     }while(e.range.offset(1   i,1).getDataValidation().getCriteriaType() == "CHECKBOX")
   }
  }
}

Demo:

enter image description here

  • Related