Hi everybody.
I have a spreadsheet, it's first column is id column.
function filterRows() {
// Get the sheet by name
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheetByName("Users")
// remove filter
const f = ws.getFilter()
if(f!=null){ws.getFilter().remove()}
// Define the range to filter (in this example, column B)
const range = ws.getRange('B1:B');
// Create the filter criteria (in this example, the value '1' in the first column)
const criteria = SpreadsheetApp.newFilterCriteria().whenTextEqualTo('1').build();
// Create the filter and apply it to the range
const filter = range.createFilter();
filter.setColumnFilterCriteria(2, criteria);
// Get the filtered rows
const filteredRows = range.getValues().filter(row => row[0] === '1');
// Log the filtered rows to the console
console.log(filteredRows);
filter.remove();
}