He intentado crear un script de Office que recorra cada fila y encuentre el que tiene el texto "Total" en la columna A y luego elimine esa fila. No he conseguido que funcione, alguien sabe como cambiarlo?
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 text "Total". If it is, then delete the entire row. for (let i = rowCount - 1; i >= 0; i--) { if (values[i][18] == "Total") { usedRange.getCell(i, 1).getEntireRow().delete(ExcelScript.DeleteShiftDirection.up) } } }Creo que tu problema está en esta línea:
if (values[i][18] == "Total") { La primera matriz [i] toma el argumento que corresponde a la fila en la hoja de cálculo de Excel. La segunda matriz [18] toma el argumento que corresponde a la columna en la hoja de cálculo de Excel. Dado que las matrices se basan en cero, la primera columna, la Columna A, correspondería al índice cero. Entonces solo tiene que actualizar el valor de 18 a 0. Y debería realizar esta verificación en la columna A. Entonces, el código actualizado se verá así:
if (values[i][0] == "Total") {