Home > Blockchain >  Repeating a value on the basis of count provided in another cell - Google Sheets
Repeating a value on the basis of count provided in another cell - Google Sheets

Time:10-01

I'm trying to write a formula where I can generate a number n number of times where n can be the input provided by the user.

=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY(
 REPT($D2&",", $E2), ), ","))))

Ideal output

Here D2 is the value to be repeated and E2 is the number of times.

So instead of manually using this formula after each last repeated value to generate the next set of repeated values, I want to print the values in one go. I'll be really grateful, if anyone could please provide a way around to do the same. Thanks in advance.

CodePudding user response:

Try this

=ARRAY_CONSTRAIN(arrayformula(query(flatten(split(rept("|"&D2:D,E2:E),"|")),"select * where Col1 is not null")),SUM(E2:E),1)

CodePudding user response:

Try the below formula:

=ARRAYFORMULA(TRIM(TRANSPOSE(SPLIT(QUERY(
 REPT(D2:D&",", E2:E), ,999^99), ","))))
  • Related