I am trying to show/hide ranges of rows in one google sheet dependent upon the input in various cells. I am currently using below code for one of the sections of the sheet, but is not working correctly. How would I fix this so that depending on if the user selects "Yes" or "No" in a dropdown cell, a specific range of rows would either be shown or hidden?
var SHEET = "Questionnaire";
var VALUE = "Yes";
var HIDEVALUE = "No";
var COLUMN_NUMBER = 6
var ROW_NUMBER = 42
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activeSheet = ss.getActiveSheet();
if(SHEET == activeSheet.getName()){
var cell = ss.getActiveCell()
var cellValue = cell.getValue();
if(cell.getColumn() == COLUMN_NUMBER && cell.getRow() == ROW_NUMBER){
if(cellValue == VALUE){
activeSheet.showRows(46,52)
};
};
};
}
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activeSheet = ss.getActiveSheet();
if(SHEET == activeSheet.getName()){
var cell = ss.getActiveCell()
var cellValue = cell.getValue();
if(cell.getColumn() == COLUMN_NUMBER && cell.getRow() == ROW_NUMBER){
if(cellValue == HIDEVALUE){
activeSheet.hideRows(46,52)
};
};
};
}