Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
Repita el guión hasta que se cumplan las condiciones

Tengo una hoja de Google con un temporizador configurado para las 5 am y todos los días quiero que la hoja:

  1. Actualizar, que incluye algunos enlaces a datos externos, por lo que agrego una pausa de 10 segundos. Hay aproximadamente 100 filas.
  2. Escribí con éxito una fórmula en la columna U para decirme si los datos se importaron correctamente y, si no, devuelve el texto "ERROR".
  3. Busque "ERROR" en la columna U.
  4. Si hay algún "ERROR" en la columna U, actualice la página nuevamente y espere 10 segundos.
  5. Repita hasta que no haya "ERRORES"
  6. Solo cuando no haya "ERRORES" en la columna U, copie los valores en la columna V y pegue los valores en la columna W.

Creo que estoy cerca ... Simplemente no puedo entender cómo decirle que vuelva a ejecutar la parte "SI" si todavía encuentra "ERRORES". ¡Cualquier entrada es apreciada!

Aquí hay un enlace al archivo -> https://docs.google.com/spreadsheets/d/1GFN3tXRlqxo9J9iNpZMPk-e-WlNGVjJ4zSqZ1_aEE_U

 function HardKeyValues() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Players'), true); SpreadsheetApp.flush(); Utilities.sleep(10000); var findVal = spreadsheet.getRange('U:U').getValue() if(findVal.match('ERROR')){ SpreadsheetApp.flush(); Utilities.sleep(10000)} else{ spreadsheet.getRange('W:W').activate(); spreadsheet.getRange('V:V').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);} }
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

En realidad, no usaría el temporizador de apagado automático de esta manera.

Pero si lo hiciera, lo escribiría así:

 function HardKeyValues() { const ss = SpreadsheetApp.getActive(); const psh = ss.getSheetByName('Players'); SpreadsheetApp.flush(); Utilities.sleep(10000); const vs = psh.getRange('U1:U' + psh.getLastRow()).getDisplayValues().flat(); if (vs.find(e => e.includes("ERROR"))) { SpreadsheetApp.flush(); Utilities.sleep(10000); } else { sh.getRange("V1:V" + sh.getLastRow()).copyTo(sh.getRange("W1:W" + sh.getLastRow(), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false)); } }

El uso de rangos indeterminados como "W:W" a menudo conduce a muchos valores nulos al final de la matriz.

about 4 years ago · Juan Pablo Isaza Report

0

¿Qué pasa con el uso de un ciclo while?

 function HardKeyValues() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Players'), true); SpreadsheetApp.flush(); Utilities.sleep(10000); var findVal = spreadsheet.getRange('U:U').getValue() while (findVal.match('ERROR')){ SpreadsheetApp.flush(); Utilities.sleep(10000)} findVal = spreadsheet.getRange('U:U').getValue() } spreadsheet.getRange('W:W').activate(); spreadsheet.getRange('V:V').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false); }
about 4 years ago · Juan Pablo Isaza Report

0

Tal vez podría intentar usar un bucle for, solo asegúrese de tener una variable que eventualmente pueda cumplir con el requisito para que el bucle for se detenga, de lo contrario, se convertirá en un bucle para siempre;)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!