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

124
Views
How do I write a loop that concatenates my data with a word?

I have a list of words in Column A. All I want to do is add the word "MASTER" to each word and copy and paste it to another column. Here's what I have that isn't working. How do I correct my loop to make it work.

function myJoin() {
  var sheet1 = SpreadsheetApp.getActiveSpreadsheet();
 var sh0 = sheet1.getSheets()[0];
  var lastRow = sh0.getLastRow();
   var range = sh0.getRange(1,1,lastRow,1);\\destination row

  var range2 = sh0.getRange(1,2,lastRow,1).getValue();\\my data

  for(var i=0;i<=lastRow;i++){
 

    range.setValue(range2[i]+"MASTER");
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

function myJoin() {
  var ss = SpreadsheetApp.getActive();
  //var sh = ss.getSheetByName('Sheet0');//my sheet 0 was something else
  var sh = ss.getSheets()[0];
  var vs = sh.getRange(1, 1, sh.getLastRow(), 1).getValues();
  let vA = vs.map(r => {
    return [r[0] + "Master"]
  });
  sh.getRange(1, 2, vA.length, vA[0].length).setValues(vA);
}

Learn More

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!