Google-sheets – How to print a specific number of A based on a value from a cell in Google Sheets

google sheetsgoogle-apps-script

There's a cell that would contain the number of times a letter would be printed in a cell.

i.e.

cell a1 = 3. b1 should look as "A A A"

my rough script is:

for(var arow=0; arow<4; arow++) {
  var numberofo = actsheet.getRange(arow+1,1).getValue();
     for(i=0; i<=numberofo;i++) {
         var test = actsheet.getRange(i+1,2).setValue("o");
     };
 }

Sorry the code looks rough. Haven't coded for the last 7 years.

Best Answer

Is this a scripting challenge for yourself? Or are you actually trying to solve a real-world problem. If the latter, you don't need script, just a formula:

=REPT("A",A1)