On google sheets trying to hide/unhide rows based on the values in particular cells, and trying to write a script in AppsScript for that. Found that one that works in isolation (if B55=NO it hides 64 next rows):
function onEdit(e) {
var activeSheet = e.source.getActiveSheet();
var range = e.range;
if (activeSheet.getName() !== 'Inputs' || range.getA1Notation() !== 'B55') return;
if (e.value === 'No') {
activeSheet.hideRows(56, 64);
} else if (e.value === 'Yes') {
activeSheet.showRows(56, 64);
}
}
But I need the same for Multiple Cells and multiple rows, as soon as I expand it only last part of the code works and not the first:
function onEdit(e) {
var activeSheet = e.source.getActiveSheet();
var range = e.range;
if (activeSheet.getName() !== 'Inputs' || range.getA1Notation() !== 'B55') return;
if (e.value === 'No') {
activeSheet.hideRows(56, 64);
} else if (e.value === 'Yes') {
activeSheet.showRows(56, 64);
}
}
function onEdit(e) {
var activeSheet = e.source.getActiveSheet();
var range = e.range;
if (activeSheet.getName() !== 'Inputs' || range.getA1Notation() !== 'B121') return;
if (e.value === 'No') {
activeSheet.hideRows(122, 67);
} else if (e.value === 'Yes') {
activeSheet.showRows(122, 67);
}
}
From here Cell B121 is working, but my B55 Stops working. Any tips? thanks!