CHOOSEROWS
Returns selected rows from an array or range.
CHOOSEROWS builds a new spilled array containing only the requested rows, in the
order provided.
The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=CHOOSEROWS(array, row_num1, [row_num2], ...)
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
array | range or any (range) | Required | — |
row_num1 | number | Required | — |
row_num2 | value | Optional | — |
Accepts a variable number of arguments. Minimum: 2.
Remarks
- Row indexes are 1-based; negative indexes count from the end (
-1is last row). - Repeated indexes are allowed and duplicate rows in the output.
- The result spills as an array unless it collapses to a single cell.
Error cases
- Index
0or out-of-bounds indexes return#VALUE!.
Examples
Select the middle row from a three-row array.
Formula =CHOOSEROWS({1,2;3,4;5,6},2)
Expected result {3, 4}
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Use a negative index to select the last row before the first.
Formula =CHOOSEROWS({1,2;3,4;5,6},-1,1)
Expected result {5, 6; 1, 2}
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
A one-cell array has a first row.
Formula =CHOOSEROWS({7},1)
Expected result 7
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
A row index outside the array cannot be selected.
Formula =CHOOSEROWS({1,2;3,4;5,6},4)
Expected result #VALUE!
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Pick first and last rows
Formula =CHOOSEROWS(A1:A3,1,-1)
| A | |
|---|---|
| 1 | "Jan" |
| 2 | "Feb" |
| 3 | "Mar" |
Expected result {"Jan"; "Mar"}
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Duplicate a row in output
Formula =CHOOSEROWS(A1:A2,2,2)
| A | |
|---|---|
| 1 | 5 |
| 2 | 9 |
Expected result {9; 9}
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Related functions
FAQ
Can I return rows in a custom order?
Yes. CHOOSEROWS returns rows in the exact order of the supplied indexes, and repeated indexes duplicate rows.
When does CHOOSEROWS return #VALUE!?
It returns #VALUE! for index 0 and for row indexes outside the source height after applying negative-index conversion.