SOLVED

# Creating a dynamic repeating sequence of arrays

Occasional Contributor

# Creating a dynamic repeating sequence of arrays

Hi Excel community,

I'm trying to find a way to create a dynamic array of repeating cells. I was attempting a similar technique on Google Sheets where you can use a Rept and TextJoin to create a string of the right number of elements, and then a Split function to separate them into rows.

However I haven't been able to find a way to do this in Excel; I get stumped on the split step. Would anyone have any suggestions on how to go about this?

Here's a visual example of what I'm trying to achieve:

For reference I'm using Office 365 on a mac. Perhaps I am thinking about this problem in the wrong way. Any direction I could investigate would be really helpful.

Thanks!

7 Replies

# Re: Creating a dynamic repeating sequence of arrays

``````Sub names_array()

Dim i As Integer
Dim lngzeilemax As Integer
Dim z As Integer
Dim y As Integer

With Tabelle1

lngzeilemax = .Range("B" & .Rows.Count).End(xlUp).Row

For i = 3 To lngzeilemax * Cells(1, 2).Value

For z = 1 To Cells(1, 2).Value

Cells(z + y, 3).Value = Cells(i, 2).Value

Next z

y = y + Cells(1, 2).Value

Next i

End With

End Sub``````

Maybe with this code. You can click the button in cell E2 in the attached file to start the macro.

best response confirmed by ElRafaVaz33 (Occasional Contributor)
Solution

# Re: Creating a dynamic repeating sequence of arrays

@ElRafaVaz33 There are lots of possibilities.  Here is one:

``=LET(in,F1:F6,rep,G1,s,SEQUENCE(ROWS(in)*rep,1,0),INDEX(in,QUOTIENT(s,rep)+1))``

# Re: Creating a dynamic repeating sequence of arrays

An alternative could be Power Query like in the attached file.

# Re: Creating a dynamic repeating sequence of arrays

Presuming names in A1:A3:
=TOCOL(CHOOSECOLS(A1:A3,1,SEQUENCE(3,1,1,0)))

*TOCOL and CHOOSECOLS are available with Insider (beta channel).

# Re: Creating a dynamic repeating sequence of arrays

This is perfect, thank you! I'd never heard of the LET function, but reading on it, it looks super powerful.

For anyone reading this after me, here the source list is given from F1:F6 while G1 holds the number of repetitions.

# Re: Creating a dynamic repeating sequence of arrays

YES, LET() is SUPER awesome addition. If you don't know about it definitely learn. Also look into FILTER, SORT, UNIQUE, and then LAMBDA (which gets a little more complicated but even more powerful). Some great things happening in Excelverse