Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

328
Vistas
Office Script For-each loop para encontrar texto en la columna

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) } } }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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") {
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda