Sequence Formula

XxCALLofBOOTYxX

New Member
Joined
Jan 12, 2009
Messages
41
Below I have written a sequence of #'s in Red. I would like to be able to type in my sequence (usually a 1-20 digit #) and then put how many iterations i would need in Red below that. I would then get my sequence generated in column "A". Thanks in advance to anyone who gives this a shot.


1Sequence:122144
2Iterations:3
2
1
4
4
1
2
2
1
4
4
1
2
2
1
4
4

<tbody>
</tbody>
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try:

ABCDEFGH
11Sequence:122144
22Iterations:3
32
41
54
64
71
82
92
101
114
124
131

<tbody>
</tbody>


Sheet4

Worksheet Formulas
CellFormula
A1=IF(ROW()>$C$2*COUNTA($C$1:$Z$1),"",INDEX($C$1:$Z$1,MOD(ROW()-1,COUNTA($C$1:$Z$1))+1))

<tbody>
</tbody>

<tbody>
</tbody>



We will need to tweak it a bit if you don't start in row 1.
 
Last edited:
Upvote 0
Looks like you are all set (Eric is the man), but just offering a Power Query option.

Create two tables... 1) With the number of iterations you want in it, then bring it into power query, then drill down first cell, then label table 'Iterations', then create connection only. 2) A table with your sequence (broken out in rows, like below).

Table 1)

No. Of Iterations
3

<tbody>
</tbody>



Table 2)

Sequence
1
2
2
1
4
4

<tbody>
</tbody>



Table 2 code (table name might need changing, depending), then bring it into a table and refresh as needed:

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Filtered Rows" = Table.SelectRows(Source, each ([Sequence] <> null)),
    RepeatRows = Table.Repeat(#"Filtered Rows",Iterations)
in
    RepeatRows

Delivered Result:

Sequence
1
2
2
1
4
4
1
2
2
1
4
4
1
2
2
1
4
4

<tbody>
</tbody>
 
Last edited:
Upvote 0
And here is a macro solution that will work no matter how many numbers there are in your sequence...
Code:
[table="width: 500"]
[tr]
	[td]Sub RepeatedSequence()
  Dim Seq As String, Nums() As String
  Nums = Split(Application.Rept(Join(Application.Index(Range("C1", Cells(1, Columns.Count).End(xlToLeft)).Value, 1, 0)) & " ", Range("C2")))
  Range("A1").Resize(UBound(Nums)) = Application.Transpose(Nums)
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,215,274
Messages
6,123,993
Members
449,137
Latest member
abdahsankhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top