-1

I've searched and cant find the answer to this seemingly easy task

I'm looking to repeat A1:A4 n times

A1:A4=

California

Off

Texas

Off

Desired output: n=4

California

Off

Texas

Off

California

Off

Texas

Off

California

Off

Texas

Off

California

Off

Texas

Off

TheMaster
  • 45,448
  • 6
  • 62
  • 85
taaka
  • 11
  • 2
  • Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See [tag info page](https://stackoverflow.com/tags/google-apps-script/info) for official documentation, free resources and more details. – TheMaster Sep 30 '22 at 07:28
  • See my answer [here](https://stackoverflow.com/a/73906610/) – TheMaster Sep 30 '22 at 09:27

2 Answers2

0

There are multiple ways to repeat text in columns:

Solution 1:

 =FLATTEN(TRANSPOSE(ARRAYFORMULA(SPLIT(REPT(A1:A4&";",B1),";"))))

Where B1 is the number of the repetition.

Solution 2:

You may also use Join

=transpose(split(rept(join(",",A1:A4)&",",4),","))

Solution 3:

You can also use TextJoin

=FLATTEN(split(REPT(TEXTJOIN("^",TRUE,(A2:A),"^"),B2),"\^"))

Result:

enter image description here

SputnikDrunk2
  • 3,398
  • 1
  • 5
  • 17
Twilight
  • 1,399
  • 2
  • 11
-1

try:

=INDEX(FLATTEN(TEXT(TRANSPOSE(A1:A4); FLATTEN(SPLIT(REPT("@×"; 4); "×")))))

enter image description here

enter image description here

or see: https://stackoverflow.com/a/54266697/5632629

player0
  • 124,011
  • 12
  • 67
  • 124