Google Sheets中实现基于自定义起始值的1-12循环滚动序列
Cyclic Wrap-Around Sequence in Google Sheets
If you want a 3x4 sequence that starts at a custom number and wraps around from 12 back to 1 seamlessly, here’s a simple, dynamic formula solution:
Step 1: Set your starting number
First, pick a cell (e.g., A1) to hold your starting value. This is the cell you’ll edit to adjust where the sequence begins.
Step 2: Enter the cyclic sequence formula
In the top-left cell of your target 3x4 grid (e.g., B1), paste this formula:
=ARRAYFORMULA(MOD(A1 + SEQUENCE(3,4) - 2, 12) + 1)
How this formula works:
Let’s break it down so you understand each part:
SEQUENCE(3,4): Generates a 3-row, 4-column grid of numbers from 1 to 12, marking each position in your sequence.A1 + SEQUENCE(3,4) - 2: Adjusts each position to offset from your starting number. For example, ifA1=4, this calculates4 + [1-12] -2to get values from 3 to 14.MOD(...,12): Handles the wrap-around logic. Any number over 12 gets converted to its remainder when divided by 12 (so 13 becomes 1, 14 becomes 2, etc.).+1: Converts the 0-11 range from the MOD function back to the 1-12 numbers you need.
Example outputs:
- When
A1=1: You get the original sequence:1 2 3 45 6 7 89 10 11 12 - When
A1=4: The sequence wraps as desired:4 5 6 78 9 10 1112 1 2 3 - When
A1=12: It starts at 12 and loops back to 1:12 1 2 34 5 6 78 9 10 11
Customization tip:
If you need a different grid size (like 2 rows × 6 columns) but still want the 1-12 cyclic sequence, just update the SEQUENCE parameters (e.g., SEQUENCE(2,6)). The rest of the formula stays the same since we’re still working with 12 total elements.
内容的提问来源于stack exchange,提问作者James Medford
相关产品推荐
相关产品推荐

