I am making an Office Script that should delete a row based on part of the text in a cell in the first column. The trigger word should be "Applied" but it is often more text after the first word, i.e. "Applied formula" or "Applied number".
The Script:
function main(workbook: ExcelScript.Workbook) {
//getting the used range in the worksheet
let usedRange = workbook.getActiveWorksheet().getUsedRange();
//getting the row count of the used range
let lastRow = usedRange.getRowCount();
usedRange = workbook.getActiveWorksheet().getRangeByIndexes(0, 0, (usedRange.getRowIndex() + lastRow), 19)
//getting the values of the range
let values = usedRange.getValues();
//getting the row count of the range
let rowCount = usedRange.getRowCount();
//for every row starting at the last row, checking if the cell in column 'A' contains part of text "Applied". If it is, then delete the entire row.
for (let i = rowCount - 1; i >= 0; i--) {
if (values[i][0] == "Applied*") {
usedRange.getCell(i, 0).getEntireRow().delete(ExcelScript.DeleteShiftDirection.up)
}
}
}
I can not get it to work, should there be something else instead of the "*" after Applied in the last part of the script?
Thank you in advance