Instead of reviving an old thread that was posted years ago, I decided to start a new one. You can find the original thread here.
In the previous discussion, I discovered the script I needed to remove filters in a sheet:
function clearFilter() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ssId = ss.getId();
var sheetId = ss.getActiveSheet().getSheetId();
var requests = [{
"clearBasicFilter": {
"sheetId": sheetId
}
}];
Sheets.Spreadsheets.batchUpdate({'requests': requests}, ssId);
}
The issue is that this code only removes filters in the currently active sheet. What I actually want to do is remove filters in ALL sheets.
This is my attempt at modifying the code:
function clearFilter() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ssId = ss.getId();
var sheetId = ss.getActiveSheet().getSheetId();
var requests = [{
"clearBasicFilter": {
"sheetId": sheetId
}
}];
for(var i = 0; i < ss.length; i++) {
Sheets.Spreadsheets.batchUpdate({'requests': requests}, ssId);
}
}
I tried adding a for loop to iterate through all sheets in the workbook, but it seems like my implementation is incorrect. Can anyone provide assistance with this issue?