Can I combine these scripts to work like a toggle to hide or show rows?
function onEdit(e){
if (e.range.columnStart != 1 || e.value != "FALSE") return;
SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
sheet.hideRows(23,4); // Hides rows
}
function onEdit(e){
if (e.range.columnStart != 1 || e.value != "TRUE") return;
SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
sheet.showRows(23,4); // Shows rows
}
CodePudding user response:
function onEdit(e){
//if e.vlaue represent the current state of the records are shown/hide
if (e.range.columnStart != 1 ) return;
SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
if ( e.value != "FALSE"){
sheet.showRows(23,4); // Shows rows
}else{
sheet.hideRows(23,4); // Hides rows
}
}
CodePudding user response:
function onEdit(e){
const sh = e.range.getSheet();
if(sh.getName() == "Enter Sheet Name" && e.range.columnStart > 1 ) {
if(e.value == "TRUE") sh.showRows(23,4);
if(e.value == "FALSE") sh.hideRows(23,4);
}
}
You did not specify the checkbox row.