I am trying something reasonably simple but can’t get it to work:
I want to hide multiple columns and/or rows based on the value of a cell.
I have it working with a simple script however it seems to only do its job when the trigger cell in question has the value input manually, i.e. I have a drop-down list of “0” & “1” and when I change it manually from “0” to “1” it all works.
However, the cell in question gets its value itself from a simple if condition and even though the value is, in the end, the same it seems the script is not working in such a case.
I would be grateful for any help.
That's the script I found online and is apart from not being triggered correctly in my case very useful:
//TITLE:
//Hide a row if a value is inputted.
//**GLOBALS**
// Sheet the data is on.
var SHEET = "TEST2";
// The value that will cause the row to hide.
var VALUE = "1";
// The column we will be using
var COLUMN_NUMBER = 1
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activeSheet = ss.getActiveSheet();
//Ensure on correct sheet.
if(SHEET == activeSheet.getName()){
var cell = ss.getActiveCell()
var cellValue = cell.getValue();
//Ensure we are looking at the correct column.
if(cell.getColumn() == COLUMN_NUMBER){
//If the cell matched the value we require,hide the row.
if(cellValue == VALUE){
activeSheet.hideRow(cell);
};
};
};
}
The cell(s) in question use this simple line:
=IF(INDIRECT("A4")=1,"0",IF(E10="NON-FACS",1,0))
Current outcome is: Nothing happens (except when input manually)
The expected outcome is: column number 1 should be hidden