Generate Cyclical Sequences

Cubist

Well-known Member
Joined
Oct 5, 2023
Messages
811
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I'm wondering if there's a better way than what I'm doing to generate a cyclical sequence given the length and number of elements in each cycle. For example, I'm generating a sequence of length 21 rows. Each of the cycle consists of 3 elements (1,2,3).

Book1
ABC
1Length21
2Num of element in each cycle3
3
4
5
61
72
83
91
102
113
121
132
143
151
162
173
181
192
203
211
222
233
241
252
263
27
Sheet3
Cell Formulas
RangeFormula
A6:A26A6=LET(m,MOD(SEQUENCE(B1),B2),IF(m=0,B2,m))
Dynamic array formulas.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
a slightly shorter way

Excel Formula:
=MOD(SEQUENCE(B1)-1,B2)+1
 
Upvote 0
Another way
Excel Formula:
=MOD(SEQUENCE(B1,,0),B2)+1
 
Upvote 0
Solution
Both work, however, Fluff's is a tad shorter without the -1. Thank you for the answers.
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,661
Members
449,114
Latest member
aides

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