Generate Repeated Sequences

Cubist

Well-known Member
Joined
Oct 5, 2023
Messages
1,911
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,

I'm wondering if this is possible with formula. Generating an alphabetical sequence of length m, and repetition of each element n times. m is assumed to be divisible by n. For example, m=10, n = 2.

Book1
ABC
1Length10
2Rep of each element2
3
4A
5A
6B
7B
8C
9C
10D
11D
12E
13E
14
Sheet3
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
there are many ways could do that, below is one of them.
工作簿1
ABC
1Length10
2Rep of each element2
3
4A
5A
6B
7B
8C
9C
10D
11D
12E
13E
14F
15F
16G
17G
18H
19H
20I
21I
22J
23J
24
Sheet1
Cell Formulas
RangeFormula
B4:B23B4=TOCOL(TAKE(CHAR(ROW(65:90)),B1)&T(SEQUENCE(,B2)))
Dynamic array formulas.
 
Upvote 0
I just needed minor adjustment to get the length of 10 rather than 10 alphabetical. I've never seen T function before. This is neat.

Book1
ABCD
1Length10
2Rep of each element2
3
4A
5A
6B
7B
8C
9C
10D
11D
12E
13E
14
Sheet4
Cell Formulas
RangeFormula
B4:B13B4=TOCOL(TAKE(CHAR(ROW(65:90)),B1/B2)&T(SEQUENCE(,B2)))
Dynamic array formulas.
 
Upvote 0
oh sorry, i didn't understand your description well. now i am fully understand your requirement, the formula could be:
工作簿1
ABC
1Length12
2Rep of each element2
3
4A
5A
6B
7B
8C
9C
10D
11D
12E
13E
14F
15F
16
Sheet1
Cell Formulas
RangeFormula
B4:B15B4=TAKE(TOCOL(CHAR(ROW(65:90)&T(SEQUENCE(,B2)))),B1)
Dynamic array formulas.
 
Upvote 0
If I have understood correctly, I think this col B formula would not only be shorter, but also more robust.
I have assumed though that the alphabetical sequence does not go past "Z". If that is possible please clarify.

24 04 03.xlsm
ABCD
1Length12
2Rep of each element2
3
4AA
5AA
6BB
7BB
8CC
9CC
10DD
11DD
12EE
13EE
14FF
15FF
16
Repeat Seq
Cell Formulas
RangeFormula
B4:B15B4=CHAR(SEQUENCE(B1,,65,1/B2))
D4:D15D4=TAKE(TOCOL(CHAR(ROW(65:90)&T(SEQUENCE(,B2)))),B1)
Dynamic array formulas.


The reason I mention robustness is look what happens if a new row 1 is subsequently inserted in the worksheet.

24 04 03.xlsm
ABCD
1
2Length12
3Rep of each element2
4
5AB
6AB
7BC
8BC
9CD
10CD
11DE
12DE
13EF
14EF
15FG
16FG
17
Repeat Seq
Cell Formulas
RangeFormula
B5:B16B5=CHAR(SEQUENCE(B2,,65,1/B3))
D5:D16D5=TAKE(TOCOL(CHAR(ROW(66:91)&T(SEQUENCE(,B3)))),B2)
Dynamic array formulas.
 
Upvote 0
Solution
Hi Peter,
It's alpha only. Using decimals is also neat. I didn't know char takes decimals like that.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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