Mastering SEQUENCE & RANDARRAY in Microsoft Excel
When Spreadsheets Fight Back
Sometimes, you just need numbers:
-
A running list of IDs (1, 2, 3, …).
-
A dynamic calendar of dates.
-
A randomized set of sample values for testing.
In older Excel, you’d drag-fill cells, hardcode sequences, or use clunky formulas. But in modern Excel, two spells — SEQUENCE and RANDARRAY — make it effortless.
The Basics (Definition & Syntax)
-
SEQUENCE
=SEQUENCE(rows, [columns], [start], [step])
Generates a list of numbers in sequence.
-
RANDARRAY
=RANDARRAY([rows], [columns], [min], [max], [integer])
Creates an array of random numbers, optionally integers.
👉 In plain English:
-
SEQUENCE = “Give me ordered numbers.”
-
RANDARRAY = “Give me random numbers.”
Basic Example
-
SEQUENCE of 5 numbers
=SEQUENCE(5)
→ 1, 2, 3, 4, 5
-
SEQUENCE as Calendar
=SEQUENCE(7,,TODAY(),1)
→ Next 7 dates starting today
-
RANDARRAY with 5 random integers between 1 and 100
=RANDARRAY(5,1,1,100,TRUE)
→ Random list like: 78, 22, 95, 14, 61
Real-World Quirks (The Hidden Traps)
-
Not available in legacy Excel (pre-2019).
-
RANDARRAY recalculates on every refresh — numbers change unless frozen.
-
Spill range errors → Results need space to expand.
-
SEQUENCE defaults to 1 step unless changed (easy to overlook).
Fixes & Workarounds
-
Freeze RANDARRAY Results
Copy → Paste as Values.
-
Prevent #SPILL!
Make sure no data blocks the output cells.
-
Custom Step Sizes
Count by 10s:
=SEQUENCE(10,,10,10)
-
Control Random Decimal vs Integer
-
Decimals: leave last argument blank.
-
Integers: set last argument to TRUE.
-
Tricky Cases from the Forums (The Hidden Spells)
-
Dynamic Row Numbers
Auto-generate row IDs for any table:
=SEQUENCE(COUNTA(A2:A100)) -
Dynamic Calendar Generator
For a full month (say March 2025):
=SEQUENCE(DAY(EOMONTH(DATE(2025,3,1),0)),1,DATE(2025,3,1),1) -
Random Sample Without Duplicates
Pair RANDARRAY with SORTBY:
=SORTBY(A2:A100, RANDARRAY(ROWS(A2:A100)))
→ Random shuffle of list - Unique Random Numbers Between 1–50 (Pick 6)
=SORTBY(SEQUENCE(50), RANDARRAY(50,1))
Then wrap with INDEX(…,SEQUENCE(6))
For Ancient Versions of Excel (Pre-2019 Users)
-
SEQUENCE Alternative
=ROW(INDIRECT(“1:10”))
-
RANDARRAY Alternative
Use RANDBETWEEN:
=RANDBETWEEN(1,100)
(Drag down for multiple results — no spill)
Pro Tips (Beyond the Docs)
Forbidden Tricks They Don’t Teach in Class
-
SEQUENCE + TEXT for Auto Labels
=”Item-“&SEQUENCE(5)
→ Item-1, Item-2, …
-
RANDARRAY with SORTBY for Random Teams
=SORTBY(A2:A20, RANDARRAY(ROWS(A2:A20)))
-
Nested Sequences for Grids
=SEQUENCE(5,5)
→ 5×5 matrix of ordered numbers.
Problems → Quick Fixes at a Glance
|
Problem |
Formula Fix |
|---|---|
|
Legacy Excel (no SEQUENCE) |
=ROW(INDIRECT(“1:N”)) |
|
Legacy Excel (no RANDARRAY) |
=RANDBETWEEN(min,max) |
|
Randoms keep changing |
Copy → Paste as Values |
|
Need unique randoms |
SORTBY(SEQUENCE(N),RANDARRAY(N)) |
|
Calendar sequence |
=SEQUENCE(DAY(EOMONTH(date,0)),,date,1) |
The End of This Chapter
SEQUENCE and RANDARRAY are like summoning spells for numbers: structured when you need order, chaotic when you want randomness. They power dynamic calendars, sampling, and dashboards — all without manual typing.
Next up in the Mastering Excel series:
👉 Mastering TEXT & TEXTJOIN: Spells for Reformatting and Binding Data Together
