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

163
Vistas
Range not found when passing argument in getRangeList

I'm trying to change the font of some ranges in bold

To gain time I want to use the function getRangeList to modify all ranges at the same time

I detect the list of ranges to modify with a loop and concatenate them in a variable like this:

for(i = 0; i <= mytab.length -1; i++){
    if(condition){
      if(coord == ''){
        coord = coord + '\'A' + i + '\'' + ', \'F' + i + '\'';
      }
      else{
        coord = coord + ', \'A' + i + '\'' + ', \'F' + i + '\''; 
      }
    }
  }

The Logger.log(coord) looks as follow:

10:56:48 AM Notice  Execution started
10:56:58 AM Info    'A3', 'F3', 'A6', 'F6', 'A8', 'F8', 'A12', 'F12', 'A18', 'F18'

The issue appears when I try to use my coord variable with getRangeList

sheet.getRangeList([coord]).setFontWeight('bold');

returns "Exception: Range not found"

But when I manually write all of the values in the function it works.

sheet.getRangeList(['A3', 'F3', 'A6', 'F6', 'A8', 'F8', 'A12', 'F12', 'A18', 'F18']).setFontWeight('bold');

I think the issue might come from the commas not treated the same in a string variable and in the function itself but I can't manage to solve the problem

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use array and push instead of string and appending the range. String looking like array is still a string and will not make it an array just because you were able put it inside between brackets.

coord = [];
for(i = 0; i <= mytab.length -1; i++){
  if(condition){
    coord.push(`A${i}`)
    coord.push(`F${i}`)
  }
}
// use coord directly as it is an array now
sheet.getRangeList(coord).setFontWeight('bold');

In your code, Range is not found because it is invalid.

'A3', 'F3', 'A6', 'F6', 'A8', 'F8', 'A12', 'F12', 'A18', 'F18' is counted as one element and is not a valid range.

Note:

  • No need to use else coord has contents or not.
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