Forum Discussion
MD_Wahib
Nov 28, 2023Copper Contributor
Excel Online Script to loop through rows
I need an Excel online script to loop through rows inside the table and delete the rows based on cell value
2 Replies
- SergeiBaklanDiamond Contributor
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 .getTable("Table1") const rng = tbl .getRangeBetweenHeaderAndTotal() const value = "a" const values = rng .getValues() let id = -1; for (let row of values ) { let deleteRow = false; for (let cell of row) { if (cell.toString() == value) { deleteRow = true } } ++id if (deleteRow) { tbl.deleteRowsAt(id, 1); --id} } }
Result is
- JKPieterseSilver ContributorWhat have you tried yourself so far?