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

140
Views
How to iterate over a range and an array of data and set the iterated array values until there's no data using GAS?

This may seem simple to you, but well....here I am.

The code below sets apparently the last value Mangas to all cells in the rangeList , while it should set Alca to A10, Mangas to F10 and stop, because there are only 2 elements.

const rngs = ["A10", "F10", "J10", "A12", "F12", "J12"];
const rangeList = sheetVendSobEnc.getRangeList(rngs).getRanges();
let coresPartes = ["Alca", "Mangas"]
  for (let a = 0; a < rangeList.length; a++) {
    for (let n = 0; n < coresPartes.length; n++) {
      rangeList[a].setValue(coresPartes[n])
    }
  }

Thank you in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think what you want is this?

const rngs = ["A10", "F10", "J10", "A12", "F12", "J12"];
const rangeList = sheetVendSobEnc.getRangeList(rngs).getRanges();
let coresPartes = ["Alca", "Mangas"]
  for (let a = 0; a < rangeList.length; a++) {
    if( coresPartes[a] ===  undefined ) return;  // or break i'm no sure
    rangeList[a].setValue(coresPartes[a])
  }
}
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!