Math and trigonometry functions
SEQUENCE
Matches all 52 recorded answers
Recorded: 52 workbook cells. How we measure this · See the Rust code
Local names in 40 languages
| Language | Name in Excel |
|---|---|
| Arabic | SEQUENCE |
| Bulgarian | SEQUENCE |
| Czech | SEQUENCE |
| Danish | SEKVENS |
| German | SEQUENCE |
| Greek | SEQUENCE |
| English (Australia) | SEQUENCE |
| English (United Kingdom) | SEQUENCE |
| English (United States) | SEQUENCE |
| Spanish | SECUENCIA |
| Estonian | SEQUENCE |
| Finnish | SEKVENSSI |
| French | SEQUENCE |
| Hebrew | SEQUENCE |
| Croatian | SEQUENCE |
| Hungarian | SORSZÁMLISTA |
| Indonesian | SEQUENCE |
| Italian | SEQUENCE |
| Japanese | SEQUENCE |
| Korean | SEQUENCE |
| Lithuanian | SEQUENCE |
| Latvian | SEQUENCE |
| Norwegian | SEQUENCE |
| Dutch | VOLGORDE |
| Polish | SEKWENCJA |
| Portuguese (Brazil) | SEQUENCE |
| Portuguese (Portugal) | SEQUÊNCIA |
| Romanian | SEQUENCE |
| Russian | ПОСЛЕД |
| Slovak | SEQUENCE |
| Slovenian | SEQUENCE |
| Serbian (Latin) | SEKVENCE |
| Swedish | SEKVENS |
| Thai | SEQUENCE |
| Turkish | SIRALI |
| Ukrainian | SEQUENCE |
| Vietnamese | SEQUENCE |
| Chinese (Simplified) | SEQUENCE |
| Chinese (Hong Kong) | SEQUENCE |
| Chinese (Traditional) | SEQUENCE |
Names from Microsoft's support site.
What it does
SEQUENCE(rows, [columns], [start], [step])
SEQUENCE(rows, [columns], [start], [step]) creates a rectangular array of regularly spaced numbers. Optional arguments default to one. Microsoft also permits omitting rows when at least one other argument is supplied; the missing row count then defaults to one.
Try it
=SEQUENCE(2,3,10,2) spills these two rows:
| Column 1 | Column 2 | Column 3 |
|---|---|---|
| 10 | 12 | 14 |
| 16 | 18 | 20 |
The sequence continues across the first row before moving to the second. =SEQUENCE(,3,5,2) produces one row, 5,7,9. A negative step descends, while a zero step repeats the start value.
Quirks
The output needs enough free worksheet cells to spill. The function’s array result and the workbook’s placement decision are separate: a correct two-by-three array can still encounter a spill obstruction. Microsoft documents limited support for dynamic arrays linked across workbooks; closing the source workbook can give #REF! when the link refreshes.
The current numeric implementation accepts positive integer dimensions. A zero dimension gives #CALC!; a negative or fractional dimension gives #VALUE!. Omitted or blank arguments take their defaults. These error choices come from the implementation, since the opened Microsoft function page does not enumerate those dimension errors.
How to implement
- Prepare all four arguments, preserving formed worksheet errors. Apply the defaults before dimension checks; omission and numeric zero are different cases.
- Require finite, positive integer row and column counts. Check their product for overflow and against the host’s output limit before allocating.
- For zero-based output index
i, computestart+i*stepwith a multiply followed by an add. Store it at rowi div columns, columni mod columns. - Return an array with the requested shape. The workbook host checks its spill destination.
This is the current code’s direct-index calculation. Do not silently replace it with repeated previous+step: accumulated rounding can change the sequence. For example, the current route for SEQUENCE(1,3,10000000000000000,1) gives 10000000000000000, 10000000000000000, 10000000000000002; repeated binary64 addition of one would stay at the first value. This distinguishes two implementable algorithms, not an identified arithmetic route for every Excel build.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
SEQUENCE · 3 lines · calc-func/src/catalogue/arrays.rs on GitHub1 sequence_fn "SEQUENCE" (1, 4) [V "rows", V "columns", V "start", V "step"] resume sequence_resume => sequence_task; |s, a, sv| {
result(s, k::eval_sequence_prepared(a))
}
sequence_task · 10 lines · calc-func/src/catalogue/arrays.rs on GitHubfn sequence_task(
site: &Site<'_>,
args: &[CalcValue],
_: &mut EvalServices<'_>,
) -> Step<Box<dyn crate::call::KernelTask>> {
Ok(Box::new(SequenceTask(result(
site,
k::SequenceWork::new(args),
)?)))
}
new · 6 lines · calc-func/src/ported/dynamic_array_reshape_family.rs on GitHubfn new(arg: &'a CalcValue) -> Self {
match arg.core_ref() {
CoreRef::Array(array) => Self::Array(array),
_ => Self::Scalar(scalar_cell(arg)),
}
}
SequenceWork::new · 55 lines · calc-func/src/ported/dynamic_array_reshape_family.rs on GitHubpub(crate) fn new(args: &[CalcValue]) -> Result<Self, DynamicArrayReshapeEvalError> {
// Fn2 roots164/165: formed argument errors keep their order before a
// dimension-derived error. Arrays and callable values keep their own route.
for value in args {
if value.callable_value().is_none()
&& let CoreRef::Error(code) = value.core_ref()
{
return Err(DynamicArrayReshapeEvalError::Preparation(
CoercionError::WorksheetError(code),
));
}
}
fn dimension(arg: Option<&CalcValue>) -> Result<usize, DynamicArrayReshapeEvalError> {
let raw = match arg {
None => return Ok(1),
Some(value) if matches!(value.core_ref(), CoreRef::Missing | CoreRef::Empty) => {
return Ok(1);
}
Some(value) => coerce_prepared_to_number(value)
.map_err(DynamicArrayReshapeEvalError::Preparation)?,
};
if raw == 0.0 {
return Err(DynamicArrayReshapeEvalError::EmptyArrayResult);
}
if !raw.is_finite() || raw < 0.0 || raw.fract() != 0.0 {
return Err(DynamicArrayReshapeEvalError::InvalidCount);
}
Ok(raw as usize)
}
fn scalar(arg: Option<&CalcValue>) -> Result<f64, DynamicArrayReshapeEvalError> {
match arg {
None => Ok(1.0),
Some(value) if matches!(value.core_ref(), CoreRef::Missing | CoreRef::Empty) => {
Ok(1.0)
}
Some(value) => coerce_prepared_to_number(value)
.map_err(DynamicArrayReshapeEvalError::Preparation),
}
}
let rows = dimension(args.first())?;
let cols = dimension(args.get(1))?;
let start = scalar(args.get(2))?;
let step = scalar(args.get(3))?;
let count = ArrayShape { rows, cols }
.cell_count()
.ok_or(DynamicArrayReshapeEvalError::InvalidCount)?;
Ok(Self {
rows,
cols,
start,
step,
count,
cells: Vec::new(),
})
}
SequenceWork::advance · 12 lines · calc-func/src/ported/dynamic_array_reshape_family.rs on GitHubpub(crate) fn advance(
&mut self,
elements: usize,
) -> Option<Result<CalcValue, DynamicArrayReshapeEvalError>> {
let end = self.cells.len().saturating_add(elements).min(self.count);
for idx in self.cells.len()..end {
self.cells
.push(CalcValue::number(self.start + (idx as f64) * self.step));
}
(end == self.count)
.then(|| build_array(self.rows, self.cols, std::mem::take(&mut self.cells)))
}
eval_sequence_prepared · 7 lines · calc-func/src/ported/dynamic_array_reshape_family.rs on GitHubpub fn eval_sequence_prepared(
args: &[CalcValue],
) -> Result<CalcValue, DynamicArrayReshapeEvalError> {
SequenceWork::new(args)?
.advance(usize::MAX)
.expect("unlimited sequence completes")
}
Kernels shared with other functions
resultcatalogue/arrayscoerce_prepared_to_numberported/dynamic_array_reshape_familyscalar_cellported/dynamic_array_reshape_familygetported/dynamic_array_reshape_familybuild_arrayported/dynamic_array_reshape_familymap_dynamic_array_reshape_error_to_wsported/dynamic_array_reshape_family
Argument and result plumbing
No implementation has been published with a Handbook test suite for this function.
Version differences
No same-input comparison between named Excel builds is recorded for this function here. The documented behaviour below is not a measurement of every Excel release.
Alternatives
MAKEARRAY computes each entry from coordinates; RANDARRAY generates random entries; SCAN returns intermediate accumulator values.
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents