I have a simple formula in column A that returns True or False against rows depending on the value of cell I3. At the moment, each time I change the value of cell I3 I have to manually go to the filter and select "OK" to refresh it. Can this be run be a script that is triggered by any edit to cell I3?
https://docs.google.com/spreadsheets/d/1H2lkC-rQKjdL_7A8t0_mNNzk4OJr0iQi0wsja0rQ-7w/edit#gid=893032115
Yes, you can automate the filter if cell I3 is edited. I'm not an expert in filters (particularly scripted), so I created and re-used a macro.
function onEdit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet()
var sheetname = "P&L";
var sheet = ss.getSheetByName(sheetname);
var erow = e.range.getRow();
// Logger.log("DEBUG: row = "+erow);
var ecolumn = e.range.getColumn();
// Logger.log("DEBUG: column = "+ecolumn);
if (erow == 3 || ecolumn == 8 ){
// there is a match so the cell is I3
// Logger.log("DEBUG: the cell is I3");
updatefilter();
}
else
{
// there is no match so the cell is NOT I3
//Logger.log("DEBUG: the cell is not I3");
}
}
function updatefilter() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('V3').activate();
var criteria = SpreadsheetApp.newFilterCriteria()
.setHiddenValues(['', 'No'])
.build();
spreadsheet.getActiveSheet().getFilter().setColumnFilterCriteria(22, criteria);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With