Lookup and reference functions
ROWS
Known larger differences on 22 of 975 recorded answers
Of 975 recorded answers (975 workbook cells), 22 do not match: 6 differ in kind or value, 16 are refused. How we measure this · See the Rust code
Local names in 40 languages
| Language | Name in Excel |
|---|---|
| Arabic | ROWS |
| Bulgarian | ROWS |
| Czech | ROWS |
| Danish | RÆKKER |
| German | ROWS |
| Greek | ROWS |
| English (Australia) | ROWS |
| English (United Kingdom) | ROWS |
| English (United States) | ROWS |
| Spanish | FILAS |
| Estonian | ROWS |
| Finnish | RIVIT |
| French | ROWS |
| Hebrew | ROWS |
| Croatian | ROWS |
| Hungarian | ROWS |
| Indonesian | ROWS |
| Italian | ROWS |
| Japanese | ROWS |
| Korean | ROWS |
| Lithuanian | ROWS |
| Latvian | ROWS |
| Norwegian | ROWS |
| Dutch | ROWS |
| Polish | ROWS |
| Portuguese (Brazil) | ROWS |
| Portuguese (Portugal) | ROWS |
| Romanian | ROWS |
| Russian | ROWS |
| Slovak | ROWS |
| Slovenian | ROWS |
| Serbian (Latin) | ROWS |
| Swedish | ROWS |
| Thai | ROWS |
| Turkish | SATIRSAY |
| Ukrainian | ROWS |
| Vietnamese | ROWS |
| Chinese (Simplified) | ROWS |
| Chinese (Hong Kong) | ROWS |
| Chinese (Traditional) | ROWS |
Names from Microsoft's support site.
What it does
ROWS(array)
ROWS returns the number of rows in its argument, as a scalar number.
For a reference, that is the row span of the referenced area: ROWS(A5:C9) is 5. For a
single cell it is 1. For an array — a literal, a dynamic-array result, or the value returned
by another function — it is the array's first dimension: ROWS({1,2;3,4}) is 2.
The whole function is that one sentence, which is why it is worth being exact about the two things it is not:
- It is not
ROW.ROWreports which rows;ROWSreports how many.ROW(A5:A8)is the array{5;6;7;8};ROWS(A5:A8)is4. - It does not count populated rows.
ROWSmeasures the shape of the reference, not its contents. A range with three blank rows in the middle still has its full row count. Counting data isCOUNTA's job, and mistaking one for the other is the usual source of off-by-many errors in "dynamic range" formulas.
The function's real importance is structural: it is how a formula asks about the shape of
something it was handed. ROWS and COLUMNS are the shape-introspection primitives that make
generic array formulas possible, and they are what a LAMBDA uses to size its own work.
Arguments
array — required, exactly one. A reference or an array whose row count is wanted. Both
argument kinds are admissible: the argument name in the signature says array, but a reference
is equally valid, and in practice references are the common case.
Try it
Quirks
Result and edge cases
The return kind is always a scalar number — never an array, whatever the argument's shape.
- Whole-column references return the grid's full row count, which differs between the
modern grid and an
.xls-compatibility workbook.ROWS(A:A)is a version-scoped answer. - Multi-area references are not described by the documentation, and the Handbook has not
verified what
ROWSdoes with a union. - Reference resolution, and the fact that
ROWSinspects the reference rather than its values, are covered in the call pipeline.
Errors
Microsoft's documentation for ROWS names no error values. Observable failures come from
elsewhere: a #REF! reference propagates, and an argument of the wrong kind is refused at
entry.
Whether an error value passed directly (ROWS(#N/A)) propagates or is treated as a 1×1
shape is not documented, and the Handbook has not verified it.
How to implement
Notes for implementers
- The answer must be a scalar, always. Returning a 1×1 array is wrong in a way that will not show up until the result is nested inside something shape-sensitive.
- The argument must not be dereferenced.
ROWSof a whole column must not require reading a million cells. - The 1×1-array-versus-scalar distinction is load-bearing. Argument preparation normally
collapses a single-cell reference to a scalar;
ROWSneeds the shape that existed before that collapse, or it needs the reference itself. - Whole-column and whole-row answers are grid-size dependent and therefore workbook- compatibility dependent. Hard-coding the modern grid's row count makes the function silently wrong on legacy workbooks.
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.
ROWS · 7 lines · calc-func/src/catalogue/lookup.rs on GitHubeager(
ROWS,
"ROWS",
CallableArityShape::exact(1),
&[Parameter::value_or_reference("array")],
rows,
)
rows · 10 lines · calc-func/src/catalogue/lookup.rs on GitHub/// ROWS(array): the rows of a reference's single area or of an array; a single value has one; an
/// error is the result; a reference of several areas is #REF!, and a blank or omitted argument
/// #VALUE!.
fn rows(
arguments: &[CalcValue],
services: &mut EvalServices<'_>,
) -> Result<CalcValue, FunctionFault> {
let site = Site::new(ROWS, services);
Site::finish(extent(&site, &arguments[0], true))
}
Kernels shared with other functions
eagercatalogue/lookuppatterncatalogue/lookupmatchescatalogue/lookupLine::lencatalogue/lookupLine::scancatalogue/lookupreadercatalogue/lookupcell_valuecatalogue/lookuprowscatalogue/lookupcolumnscatalogue/lookupvaluecatalogue/lookupspancatalogue/lookupshapecatalogue/lookupindex_numbercatalogue/lookupindexcatalogue/lookupselectorcatalogue/lookupindexedcatalogue/lookupselectcatalogue/lookuprowcatalogue/lookupcolumncatalogue/lookupposition_ofcatalogue/lookupextentcatalogue/lookupareascatalogue/lookup
Argument and result plumbing
Parameter::value_or_referencecatalogue
No implementation has been published with a Handbook test suite for this function.
Version differences
No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.
Alternatives
Relationships
COLUMNSis the transpose: the horizontal extent, same shape of answer.ROWis the coordinate function, not the count function — see above.SEQUENCE(ROWS(x))is the modern idiom for "one index per row ofx", replacingROW(INDIRECT(...)).TRIMRANGEanswers the question people often askROWSby mistake: how big is the populated part of this range.
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents