I am trying to toggle my preset filter views on and off without having to dig through the menus. I would like to attach them to a button, but google only lets me attach a script. I came up with the following script which works but is painfully slow:
function formFilter() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
for (var i=2; i <=numRows -1; i++) {
var row =values[i];
// Column value
var myValue = row[6];
// hide values that are not MOLFORM
if (myValue == "MOLFILL" || myValue =="MOLTEST" || myValue =="MOLKIT" || myValue =="MOLLEAD" ) {
sheet.hideRows(i+1);
}
}
}
Please help me out with a better script!
There is not — yet — scripting abilities in GAS to manipulate Filters, either AutoFilters nor custom Filters…
Unfortunate since they are so useful.
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