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

162
Views
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 answers
Answer question

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 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!