This post was closed, but I have not been able to find a comparable problem elsewhere.
I'm trying to work out a script that will hide rows from an onChange() trigger. When a cell becomes "0", I want the row that cell is in to become hidden. Comments from my first post have taught me that the object passed from onChange does not contain a range. Is there a workaround that would solve this problem?
My spreadsheet has an input sheet for the backend and an output sheet for the frontend that goes to the client. I need an onChange trigger, so that as data goes to the frontend it nicely format for emailing to the client. Most importantly, I need empty ('0) rows to be hidden.
I'm new and just learning, so what I've written isn't working because onChange objects do not include a range. Thank you.
function onChange(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Client");
var cell = e.range;
var VALUE = cell.getValue();
if(VALUE == 0){
sheet.hideRow(cell);
}
}
I've also tried:
function onChange(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Client");
var cell = e.getValue();
if(cell == 0){
sheet.hideRow(cell);
}
}