2

I want to do a simple task but somehow I'm unable to do it. Assume that I have one column like:

a
z
e
r
t

How can I create a new column with the same value twice with the following result:

a
a
z
z
e
e
r
r
t
t

I've already tried to double my column and do something like :

=TRANSPOSE(SPLIT(JOIN(";",A:A,B:B),";"))

but it creates:

a
z
e
r
t
a
z
e
r
t

I get inspired by this answer so far.

Devstr
  • 4,431
  • 1
  • 18
  • 30
ZazOufUmI
  • 3,212
  • 6
  • 37
  • 67

3 Answers3

4

Try this:

=SORT({A1:A5;A1:A5})

Here we use:


Accounting your comment, then you may use this formula:

=QUERY(SORT(ArrayFormula({row(A1:A5),A1:A5;row(A1:A5),A1:A5})),"select Col2")

The idea is to use additional column of data with number of row, then sort by row, then query to get only values.


And joinsplit method will do the same: =TRANSPOSE(SPLIT(JOIN(",",ARRAYFORMULA(CONCAT(A1:A5&",",A1:A5))),","))

Here we use range only two times, so this is easier to use. Also see Concat + ArrayFormula sample.

Community
  • 1
  • 1
Max Makhrov
  • 17,309
  • 5
  • 55
  • 81
1

Few hundreds rows is nothing :)

I created index from 1 to n, then pasted it twice and sorted by index. But it's obviously fancier to do it with a formula :)

enter image description here

pawelty
  • 1,000
  • 8
  • 27
1

Assuming Your list is in column A and (for now) the times of repeat are in C1 (can be changed to a number in the formula), then something simple like this will do (starting in B1):

=INDEX(A:A,(INT(ROW()-1)/$C$1)+1)

Simply copy down as you need it (will give just 0 after the last item). No sorting. No array. No sheets/excel problems. No heavy calculations.

Dirk Reichel
  • 7,989
  • 1
  • 15
  • 31