A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Formula.
=FILTER(Sheet1!A2:C8,Sheet1!C2:C8="AAAA")
For office script, try this one.
====================================================
function main(workbook: ExcelScript.Workbook) { // Get the source worksheet let sourceSheet = workbook.getWorksheet("Sheet1");
// Get the range to filter
let range = sourceSheet.getRange("A2:C8").getValues();
// Define the filter criterion let criterion = "AAAA";
// Filter the datalet filteredData = range.filter(row => row[2] === criterion);
// Get the destination worksheet (create it if it doesn't exist)let destinationSheet = workbook.getWorksheet("FilteredData");if (!destinationSheet) {destinationSheet = workbook.addWorksheet("FilteredData");}
// Set the filtered data in the destination sheetdestinationSheet.getRange("A1:C1").setValues([["Cat No", "Amount", "Desc"]]);destinationSheet.getRange("A2").getResizedRange(filteredData.length - 1, filteredData[0].length - 1).setValues(filteredData);}