Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Excel or Google Sheets—Is there a way to duplicate rows in place using only formulas?

Using only excel/google sheets formulas, I would like to take a table like this:

a b c
q r s
x y z

and turn it into something like this:

a b c
a b c
a b c
q r s
q r s
q r s
x y z
x y z
x y z

The point is that the rows are duplicated n times but maintain the sort order of the original table.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

use in google sheets:

=LAMBDA(y, z, INDEX(SPLIT(FLATTEN(TEXT(BYROW(y, LAMBDA(x, 
 TEXTJOIN("​",,x))), IFERROR(SEQUENCE(1, z)/0, "@"))), "​")))
 (A1:C3, 3)

enter image description here

or try:

=LAMBDA(x, y, REDUCE(x, SEQUENCE(y-1), 
 LAMBDA(a, b, IF(b, {a; x}))))
 (A1:C3, 3)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading