If you look at this blog, you will find examples of the results of running GAScript scripts in Excel. Today, I will show you how to filter the entire table based on a value from a cell and how to reset it to the original result without filtering.
function reseteazaFiltrarea() {
const sheet = SpreadsheetApp.getActiveSheet();
const ultimaLinie = sheet.getLastRow();
sheet.showRows(1, ultimaLinie);
SpreadsheetApp.getUi().alert("Toate rândurile au fost afișate.");
}
function filtreazaRanduriDupaCelulaSelectata() {
const sheet = SpreadsheetApp.getActiveSheet();
const cell = sheet.getActiveCell();
const valoare = cell.getValue();
const coloanaDeFiltrare = cell.getColumn();
const ultimaLinie = sheet.getLastRow();
for (let i = 1; i <= ultimaLinie; i++) {
const valoareRand = sheet.getRange(i, coloanaDeFiltrare).getValue();
sheet.showRows(i); // asigură-te că rândul e vizibil
if (valoareRand !== valoare && i !== cell.getRow()) {
sheet.hideRows(i);
}
}
SpreadsheetApp.getUi().alert(`Filtrare aplicată pentru: ${valoare}`);
}