Excel Online Script to loop through rows

Copper Contributor

I need an Excel online script to loop through rows inside the table and delete the rows based on cell value 

2 Replies
What have you tried yourself so far?


As variant, if for such table


to remove rows with "a" in any cell, it could be

function main(workbook: ExcelScript.Workbook) {

    const tbl = workbook
    const rng = tbl
    const value = "a"
    const values = rng

    let id = -1;
    for (let row of values ) {
        let deleteRow = false;

        for (let cell of row) {
            if (cell.toString() == value) {
                deleteRow = true
        if (deleteRow) { tbl.deleteRowsAt(id, 1); --id} 

Result is